SQLA doesnt know which side of tContact is which since both columns
reference "user.user_id".  specify primaryjoin=user_id==tContact.c.user_id
and secondaryjoin = user_id==tContact.c.contact_id (or vice versa).


Geoff Corey wrote:
>
> tContact = Table('contact', metadata,
>    Column('user_id', Integer, ForeignKey('user.user_id'),
>    Column('contact_id', Integer, ForeignKey('user.user_id')
> )
>
> class User(DeclarativeBase):
>     __table_name__ = 'user'
>    user_id = Column(Integer, autoincrement=True, primary_key=True)
>    name = Column(Unicode(80))
>    contacts = relation('User', secondary=tContact)
>
> I know the statement "contacts = relation"  is wrong.   I have poured
> over examples and cannot seem to fathom how to do this relationship in
> DeclarativeBase.
>
> >
>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to