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, name): self.id = id self.name = name class Address(Base): __tablename__ = 'address' id = Column(Integer, primary_key=True) user_id = Column(Integer, ForeignKey('user.id')) def __init__(self, id, user_id): self.id = id self.user_id = user_id if we create a user then add a address User1 = User(1,"Tom") Address1 = Address('1', None) User1.addresses(Address1) print User1.Address[0].user_id after that we will get a None result ... How to automatic assign user_id when we add address to a user? Thanks. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.