make it work

This commit is contained in:
Yusur 2025-08-04 14:43:06 +02:00
parent daa9f6de0c
commit dbf85f5369

View file

@ -14,6 +14,12 @@ This software is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
""" """
from contextlib import _GeneratorContextManager
from sqlalchemy.engine.base import Connection
from __future__ import annotations from __future__ import annotations
from sqlalchemy import Engine, Select, func, select from sqlalchemy import Engine, Select, func, select
from sqlalchemy.orm import DeclarativeBase, lazyload from sqlalchemy.orm import DeclarativeBase, lazyload
@ -44,7 +50,7 @@ class SQLAlchemy:
if self.engine is None: if self.engine is None:
raise RuntimeError('database is not connected') raise RuntimeError('database is not connected')
## XXX is it accurate? ## XXX is it accurate?
s = self.engine.begin() s = AsyncSession(self.engine)
self._sessions.append(s) self._sessions.append(s)
return s return s
async def __aenter__(self) -> AsyncSession: async def __aenter__(self) -> AsyncSession: