Answers for "sqlalchemy one to one foreign key"

0

sqlalchemy one to one foreign key

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'))
Posted by: Guest on June-29-2021

Code answers related to "sqlalchemy one to one foreign key"

Python Answers by Framework

Browse Popular Code Answers by Language