Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

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)
Source by flask-sqlalchemy.palletsprojects.com #
 
PREVIOUS NEXT
Tagged: #sqlalchemy #flask
ADD COMMENT
Topic
Name
6+3 =