Answer the question
In order to leave comments, you need to log in
What is the purpose of the relationship() function in sqlalchemy?
class Family(db.Model):
__tablename__ = 'family'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(40))
with_plants = db.relationship('Plants', backref='f')
class Genus(db.Model):
__tablename__ = 'genus'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(40))
with_plants = db.relationship('Plants', backref='g')
class Plants(db.Model):
__tablename__ = 'plants'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(40))
g_id = db.Column(db.Integer, db.ForeignKey('genus.id'))
f_id = db.Column(db.Integer, db.ForeignKey('family.id'))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question