Flask-SQLAlchemy backref function and backref parameter
From the documentation for Flask models:
backref
is a simple way to also declare a new property on the Address class. You can then also use my_address.person
to get to the person at that address. lazy
defines when SQLAlchemy will load the data from the database:
select
(which is the default) means that SQLAlchemy will load the data as necessary in one go using a standard select statement.
joined
tells SQLAlchemy to load the relationship in the same query as the parent using a JOIN statement.
subquery
works like 'joined' but instead, SQLAlchemy will use a subquery.
dynamic
is special and useful if you have many items. Instead of loading the items SQLAlchemy will return another query object which you can further refine before loading the items. This is usually what you want if you expect more than a handful of items for this relationship.