Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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'))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sqlalchemy #foreign #key
ADD COMMENT
Topic
Name
5+2 =