On Thu, 31 Jul 2014, Jonathan Vanasco wrote:
yes. `backref` just lets you consolidate defining a relationship in a
single place.
`relationship` lets you specify the relationship from A to B
`backref` is a kwarg to `relationship` that lets you specify the inverse (
B to A )
class TableA():
b = relationship("TableB", backref="a")
class TableB():
pass
is the same thing as saying:
class TableA():
b = relationship("TableB")
class TableB():
a = relationship("TableA")
`backref` can either be a `String` OR a `backref()` constructor -- which
lets you customized the join with the same conditions you can elect in the
`relationship` constructor
class Foo():
bar = relationship("Bar", lots_of_keywords_here=True,
backref=backref(the_same_keywords_work_here=True) )
Jonathan,
That makes everything clear.
My original confusion arose because I'm used to specifying many children
to one parent with the postgres syntax REFERENCES in the children's table;
that's the only relationships I've used (other than many-to-many in linking
tables). The abundance of options in SQLAlchemy threw me.
Much appreciated,
Rich
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.