wuxiekeji
wuxiekeji

Reputation: 1902

How can I do a multiple-level eager load in SQLAlchemy?

I have many Cs in a B and many Bs in an A, and I have backref relationships defined. What I want to do is something like:

a = A.query().options(subqueryload(A.b).subsubqueryload(B.c)

How should this be done?

Upvotes: 8

Views: 4215

Answers (1)

van
van

Reputation: 76962

Straight from the documentation of subqueryload:

qry = query(A).options(subqueryload(A.b).subqueryload(B.c))

Upvotes: 7

Related Questions