Skip to content
Discussion options

You must be logged in to vote

hi there

basically, don't ever use this pattern, it is very wasteful and does not regenerate lazy-loaded relationships, nor in this case is it refreshing your user object:

await db.commit()
await db.refresh(item)

do this instead

SessionLocal = async_sessionmaker(autoflush=True, bind=engine, expire_on_commit=False)

see the second bullet at https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html#preventing-implicit-io-when-using-asyncsession

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by post-human-world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants