Aug-02-2018, 08:29 AM
The flask, sqlalchemy is a question.
When business_idx is the same as foreign key,
In the same case, I would like to make the duplicate name uniquely unique.
I think this can be applied in sqlalchemy during the model setup phase. What should I do?
Thank you for giving us a simple example.
When business_idx is the same as foreign key,
In the same case, I would like to make the duplicate name uniquely unique.
I think this can be applied in sqlalchemy during the model setup phase. What should I do?
Thank you for giving us a simple example.
class Member(db.Model):
__tablename__ = 'member'
index = db.Column(db.Integer, unique=True, nullable=False, primary_key=True)
business_idx = db.Column(db.Integer, db.ForeignKey('business.index'))
name = db.Column(db.String(30), nullable=False)
business = db.relationship('Business', back_populates='member')
