Do you support importing Asynchronous Sessions from sqlmodel? #1453
-
Privileged issue
Issue Content
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
here for you from sqlmodel.ext.asyncio.session import AsyncSession you can search more info in discussion if interested |
Beta Was this translation helpful? Give feedback.
-
Relatedly, suppose I wanted to use sqlmodel with https://fastapi-users.github.io/ ... the docs require that I create an async engine via More generally, want to learn how to use async io with sqlmodel |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Using the create_async_engine, I run into this issue:
tl;dr
from sqlalchemy.ext.asyncio import create_async_engine
from sqlalchemy.orm import sessionmaker
from sqlmodel.ext.asyncio.session import AsyncSession
_engine = create_async_engine(PG_URL, echo=PG_VERBOSE)
_async_session_factory = sessionmaker(_engine, class_=AsyncSession)
async with _engine.begin() as conn:
await conn.run_sync(SQLModel.metadata.create_all)
async with _async_session_factory() as session:
heroes = await session.exec(select(Hero))
heroes = heroes.all() Troubleshooting
Example codeEnvironment
|
Beta Was this translation helpful? Give feedback.
here for you
you can search more info in discussion if interested