Like this ?
------------------------------------------------------------------------------------------------
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String)
fullname = Column(String)
password = Column(String)
sons = relation('User', order_by='User.id', backref="parent")
------------------------------------------------------------------------------------------------
I got an Exception:
sqlalchemy.exc.ArgumentError: Could not determine join condition
between parent/child tables on relation User.sons. Specify a
'primaryjoin' expression. If this is a many-to-many relation,
'secondaryjoin' is needed as well.
On Feb 16, 5:08 pm, [email protected] wrote:
> put it as text, it will be eval()'uated later
>
> On Monday 16 February 2009 10:57:11 一首诗 wrote:
>
> > I tried to write :
>
> > #------------------------------------------------------------------
> >------------------ class User(Base):
> > __tablename__ = 'users'
>
> > id = Column(Integer, primary_key=True)
> > name = Column(String)
> > fullname = Column(String)
> > password = Column(String)
> > sons = relation(User, order_by=User.id, backref="parent")
> > #------------------------------------------------------------------
> >------------------
>
> > But the as 'User' is not defined at the line "... relation ... " is
> > processed, the code above doesn't work.
>
> > So, does sqlalchemy support self 2 self relationship ?
> > If the answer is "YES", how to do it?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---