Skip to content

async - can't access parent.child item (relationship models) using async #1519

Answered by rscottweekly
mnnweb asked this question in Questions
Discussion options

You must be logged in to vote

Just to flesh this out a bit, because I struggled to get it sorted and went round in circles for too long.

Import selectinload from the sqlalachemy package
from sqlalchemy.orm import selectinload

and then after the selects, add the selectinload option

statement = select(Team).where(Team.name == "Preventers").options(selectinload(Team.heroes))

Replies: 16 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested investigate
Converted from issue

This discussion was converted from issue #74 on August 14, 2025 20:03.