-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
26 lines (22 loc) · 975 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class User(db.Model):
__tablename__ = "users"
user_id = db.Column(db.Integer, primary_key = True)
name = db.Column(db.String, nullable = False)
username = db.Column(db.String, nullable = False)
password = db.Column(db.String, nullable = False)
class Book(db.Model):
__tablename__ = "books"
book_id = db.Column(db.Integer, primary_key = True)
isbn = db.Column(db.String, nullable = False)
title = db.Column(db.String, nullable = False)
author = db.Column(db.String, nullable = False)
year = db.Column(db.String, nullable = False)
class Review(db.Model):
__tablename__ = "reviews"
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, nullable = False)
book_id = db.Column(db.Integer, db.ForeignKey('books.book_id'), nullable=False)
rating = db.Column(db.Integer, nullable = True)
comment = db.Column(db.String, nullable = True)