association_table Table association Base metadata Column left_id Integ

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
association_table = Table('association', Base.metadata,
Column('left_id', Integer, ForeignKey('left.id')),
Column('right_id', Integer, ForeignKey('right.id'))
)
class Parent(Base):
__tablename__ = 'left'
id = Column(Integer, primary_key=True)
children = relationship("Child",
secondary="association",
backref="parents")
class Child(Base):
__tablename__ = 'right'
id = Column(Integer, primary_key=True)