File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
fastapi_structlog/db_handler Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 1111from sqlalchemy import create_engine
1212from sqlalchemy .engine .url import URL , make_url
1313from sqlalchemy .ext .asyncio import create_async_engine
14+ from sqlalchemy .pool import NullPool
1415from sqlmodel import Session , SQLModel
1516from sqlmodel .ext .asyncio .session import AsyncSession
1617
@@ -86,13 +87,13 @@ def emit(self, record: logging.LogRecord) -> None:
8687 self ._sync_emit (message )
8788
8889 async def _async_emit (self , record : T_ ) -> None :
89- _engine = create_async_engine (self .db_url )
90+ _engine = create_async_engine (self .db_url , poolclass = NullPool )
9091 async with AsyncSession (bind = _engine ) as session :
9192 session .add (record )
9293 await session .commit ()
9394
9495 def _sync_emit (self , record : T_ ) -> None :
95- _engine = create_engine (self .db_url )
96+ _engine = create_engine (self .db_url , poolclass = NullPool )
9697 with Session (bind = _engine ) as session :
9798 session .add (record )
9899 session .commit ()
You can’t perform that action at this time.
0 commit comments