apparently engine.begin() does not need to be awaited

This commit is contained in:
Yusur 2025-08-04 14:33:03 +02:00
parent 7478c8e404
commit 6846c763f2
2 changed files with 4 additions and 3 deletions

View file

@ -33,7 +33,7 @@ from .strtools import PrefixIdentifier
from .validators import matches from .validators import matches
from .redact import redact_url_password from .redact import redact_url_password
__version__ = "0.5.0-dev30" __version__ = "0.5.0-dev31"
__all__ = ( __all__ = (
'ConfigOptions', 'ConfigParserConfigSource', 'ConfigSource', 'ConfigValue', 'ConfigOptions', 'ConfigParserConfigSource', 'ConfigSource', 'ConfigValue',

View file

@ -41,8 +41,9 @@ class SQLAlchemy:
async def begin(self) -> AsyncSession: async def begin(self) -> AsyncSession:
if self.engine is None: if self.engine is None:
raise RuntimeError('database is not connected') raise RuntimeError('database is not connected')
return await self.engine.begin() return self.engine.begin()
__aenter__ = begin async def __aenter__(self):
return self.begin()
async def __aexit__(self, e1, e2, e3): async def __aexit__(self, e1, e2, e3):
return await self.engine.__aexit__(e1, e2, e3) return await self.engine.__aexit__(e1, e2, e3)
async def paginate(self, select: Select, *, async def paginate(self, select: Select, *,