I'm not sure I understood your question correctly as I'm very new to
sqlalchemy, still I thought u need to know how to declare ForeignKeys
in declarative style. Here is how u can declare it ; for example,
suppose you have 2 tables -
class A(Base):
__tablename__ = 'a_table'
id = Column(Integer, primary_key=True)
somecol1 = Column(Unicode(20))
class B(Base):
__tablename__='b_table'
id = Column(Integer, primary_key=True)
a_id = Column(Integer, ForeignKey('a_table.id'))
somecol2 = Column(Unicode(20))
here a_id column of b_table is foreignkey related to the id column of
a_table
On Feb 11, 9:20 am, Michael Naber <[email protected]> wrote:
> If I'm creating a relationship to a class "MyRelatedClass" using
> declarative syntax, and I need to assign a column from MyRelatedClass
> to the foreign_keys argument, it seems I have to say
> foreign_keys=[MyRelatedClass.__mapper__.c.relate_id]. Is there any way
> to just do something in the declarative style, such as:
> foreign_keys=["MyRelatedClass.relate_id"] with the quotes?
>
> Thanks,
> Michael
--
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.