Hello, everyone, I am starting to use sqlalchemy now and really got
frustrated in understanding the purpose of relationship().
For example, if I make a model with a foreign key like the one in
sqlalchemy's official docs:
class Parent(Base):
__tablename__ = 'parent'
id = Column(Integer, primary_key=True)
children = relationship("Child")
class Child(Base):
__tablename__ = 'child'
id = Column(Integer, primary_key=True)
parent_id = Column(Integer, ForeignKey('parent.id'))
so ,when I write 'parent_id = Column(Integer, ForeignKey('parent.id')), ,
have this statement already establish the relationship between child and
parent? because parent is the table name and they all live in one database,
so child can automatically fetch the data from parent.id, right? so why
bother with the relationship(), I mean, if I don't write the
relationship(), what will happen? Child can not find the parent table and
fetch its ID? I am really confused here
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.