mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
Merge pull request #101 from levinotik/patch-1
Update to use async_sessionmaker
This commit is contained in:
commit
2c1d006da8
@ -1,7 +1,7 @@
|
|||||||
from collections.abc import AsyncGenerator
|
from collections.abc import AsyncGenerator
|
||||||
|
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
|
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.ext.asyncio import async_sessionmaker
|
||||||
|
|
||||||
from app import config
|
from app import config
|
||||||
from app.utils.logging import AppLogger
|
from app.utils.logging import AppLogger
|
||||||
@ -17,7 +17,7 @@ engine = create_async_engine(
|
|||||||
|
|
||||||
# expire_on_commit=False will prevent attributes from being expired
|
# expire_on_commit=False will prevent attributes from being expired
|
||||||
# after commit.
|
# after commit.
|
||||||
AsyncSessionFactory = sessionmaker(engine, autoflush=False, expire_on_commit=False, class_=AsyncSession)
|
AsyncSessionFactory = async_sessionmaker(engine, autoflush=False, expire_on_commit=False,)
|
||||||
|
|
||||||
|
|
||||||
# Dependency
|
# Dependency
|
||||||
|
Loading…
x
Reference in New Issue
Block a user