create interface uow update services to uow

This commit is contained in:
IluaAir
2025-07-11 21:48:42 +03:00
parent 61512f70d4
commit b12bb65268
5 changed files with 20 additions and 8 deletions

18
src/core/db_manager.py Normal file
View File

@@ -0,0 +1,18 @@
from src.repository.users import UsersRepo
class DBManager:
def __init__(self, session_factory):
self.session_factory = session_factory
async def __aenter__(self):
self.session = self.session_factory()
self.user = UsersRepo(self.session)
return self
async def __aexit__(self, exc_type, exc_val, exc_tb):
await self.session.rollback()
await self.session.close()
async def commit(self):
await self.session.commit()