My question is about SQLAlchemy but I'm having troubles explaining it in words so I figured I explain it with a simple example of what I'm trying to achieve:
parent = Table('parent', metadata, Column('parent_id', Integer, primary_key=True), Column('name', Unicode), ) parent_child = Table('parent_child', metadata, Column('parent_id', Integer, primary_key=True), Column('child_id', Integer, primary_key=True), Column('number', Integer), ForeignKeyConstraint(['parent_id'], ['parent.parent_id']), ForeignKeyConstraint(['child_id'], ['child.child_id']), ) child = Table('child', metadata, Column('child_id', Integer, primary_key=True), Column('name', Unicode), ) class Parent(object): pass class ParentChild(object): pass class Child(object): pass >>> p = Parent(name=u'A') >>> print p.children {} >>> p.children[0] = Child(name=u'Child A') >>> p.children[10] = Child(name=u'Child B') >>> p.children[10] = Child(name=u'Child C') This code would create 3 rows in parent_child table, column number would be 0 for the first row, and 10 for the second and third row. >>> print p.children {0: [<Child A>], 10: [<Child B>, <Child C>]} >>> print p.children[10][0] <Child B> (I left out all SQLAlchemy session/engine code in the example to make it as clean as possible) I did a try usingĀ“ collection_class=attribute_mapped_collection('number') on a relation between Parent and ParentChild, but it only gave me one child for each number. Not a dict with lists in it. Any help appreciated! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---