how to import a sql alchemy user model code example
Example 1: set boolean flasksql
class User(db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
can_view_records = db.Column(db.Boolean, default=False, nullable=False)
Example 2: db.relationship sqlalchemy flask
class Person(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50), nullable=False)
addresses = db.relationship('Address', backref='person', lazy=True)
class Address(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(120), nullable=False)
person_id = db.Column(db.Integer, db.ForeignKey('person.id'),
nullable=False)