-
-
Notifications
You must be signed in to change notification settings - Fork 692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do you support importing Asynchronous Sessions from sqlmodel? #1218
Comments
here for you from sqlmodel.ext.asyncio.session import AsyncSession you can search more info in discussion if interested |
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 |
|
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
|
Privileged issue
Issue Content
from sqlmodel import AsyncSession
The text was updated successfully, but these errors were encountered: