Skip to content

Instantly share code, notes, and snippets.

@sampsonc
Created August 14, 2018 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sampsonc/b8c72ef05d1e763938b1257b484b7298 to your computer and use it in GitHub Desktop.
Save sampsonc/b8c72ef05d1e763938b1257b484b7298 to your computer and use it in GitHub Desktop.
#Map vip's to issues
parent_child_table = Table('parent_child', Base.metadata,
Column('parent_id', Integer, ForeignKey('parent.id')),
Column('child_id', Integer, ForeignKey('child.id')))
class Parent(Base):
__tablename__ = 'parent'
id = Column(Integer, primary_key=True)
children = relationship("Child", secondary = parent_child_table)
class Child(Base):
__tablename__ = 'child'
id = Column(Integer, primary_key=True)
parents = relationship("Parent", secondary=parent_child_table)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment