Open mitgate opened 1 year ago
I used fastapi_async_sqlalchemy instead not sure if that will help
Maybe that helps you. I do it inside the container class inherited from DeclarativeContainer (used sqlalchemy):
db_async_session = Factory(
async_sessionmaker,
bind=db_engine,
class_=AsyncSession,
expire_on_commit=False
)
your_service = Factory(YourService, session=db_async_session)
Is there any way to turn miniapps/fastapi-sqlalchemy to async ?
Im using postgresql+asyncpg on connection
replaced all classes with async ones..
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_scoped_session, async_sessionmaker
and the error when starting a session is
async with self.session_factory() as session: AttributeError: aenter