SQLAlchemy单表中的一对多关系 - 声明式

时间:2017-10-10 13:53:52

标签: sqlalchemy

我有类别和子类别,我想用父类别填充父类。我应该怎么做?

class Category(Base):
       __tablename__ = 'category'
       id = Column(UUIDType, primary_key=True)
       organisation_id = Column(UUIDType)
       category_name = Column(String(50))
       parent_category_id = Column(UUIDType, ForeignKey("category.id"))
       parent_category = relationship("Category", backref='category', 
                   remote_side=parent_category_id)

0 个答案:

没有答案