I'm looking to have a list of objects belong to a parent class, in the following manner:
class A(object):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
collection = relationship(.....) # contains an ordered list of [B, C, B, B, C, C, C, B, C, C, ...];
class B(object):
__tablename__ = 'b'
id = Column(Integer, primary_key=True)
class C(object):
__tablename__ = 'c'
id = Column(Integer, primary_key=True)
The SQLAlchemy examples folder has a simple many-to-one where, in my example, classes B and C are "parent" classes of A (rather than the other way around), but I can't for the life of me work out how to reverse this into a one-to-many, and then add a bidirectional relationship so that it becomes many-to-many.
Can anyone help me out with this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…