[sqlalchemy] how to auto set foreignkey column?

2015-08-11 Thread Sean Lin
Dear all, I have a question about how to automatic set the foreignkey column ? we have two class User and Address class User(Base): __tablename__ = 'user' id = Column(Integer, primary_key=True) name = Column(String) addresses = relationship(Address) def __init__(self, id,

Re: [sqlalchemy] how to auto set foreignkey column?

2015-08-11 Thread Ladislav Lenart
Hello. Please take a look at official examples: http://docs.sqlalchemy.org/en/rel_1_0/orm/backref.html?highlight=back_populates The first two examples use your classes (User and Address). Note the use of backref kw arg in the relationship definition (first example) and back_populates kw arg in