Re: [sqlalchemy] more than one "one to many" relation

2009-11-22 Thread Mike Conley
this should work OK if you fix the ForeignKey definitions

   Column('parent_id', Integer, ForeignKey('parent.parent_id'))
or
   Column('parent_id', Integer,ForeignKey(parent_table.c.parent_id))

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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=.




[sqlalchemy] more than one "one to many" relation

2009-11-21 Thread laurent FRANCOIS
Hello, 

What is the pattern for more than one relation "one to many".
I have on parent with 2 childs.

parent_table = Table('parent', metadata,
Column('parent_id', Integer, primary_key=True)
)
child1_table = Table('child1', metadata,
Column('child1_id', Integer, primary_key=True),
Column('parent_id', Integer,ForeignKey(parent_id))

child2_table = Table('child2', metadata,
Column('child1_id', Integer, primary_key=True),
Column('parent_id', Integer,ForeignKey(parent_id))

class Parent(object): pass
class Child1(object): pass
class Child2(object): pass

parent_map = mapper(Parent, parent_table,
properties={'child1':relation(Child1), 'child2':relation(Child2)})
child1_map = mapper(Child1, child1_table)
child2_map = mapper(Child2, child1_table)

This  mapper coding doesn't work?
What is the right way to do that?

Thanks 

--

You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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=.