Build a CRUD App with SQLAlchemy - db.relationship

db.relationship

Provides and configures a mapped relationship between two models.


请添加图片描述


  • SQLAlchemy configures the settings between model relationships once, and generates JOIN statements for us whenever we need them.
  • db.relationship is an interface offered in SQLAlchemy to provide and configure a mapped relationship between two models.
  • db.relationship is defined on the parent model, and it sets:
    • the name of its children (e.g. children), for example parent1.children
    • the name of a parent on a child using the backref, for example child1.my_amazing_parent

猜你喜欢

转载自blog.csdn.net/BSCHN123/article/details/121555930