📜  sqlalchemy 一对一外键 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:06.240000             🧑  作者: Mango

代码示例1
class Parent(Base):
    __tablename__ = 'parent'
    id = Column(Integer, primary_key=True)
    child = relationship("Child", uselist=False, backref="parent")

class Child(Base):
    __tablename__ = 'child'
    id = Column(Integer, primary_key=True)
    parent_id = Column(Integer, ForeignKey('parent.id'))