service_man/api/uow/uow_base.py

24 lines
605 B
Python
Raw Normal View History

2024-03-04 13:15:28 +03:00
from contextlib import AbstractContextManager
from typing import Iterable
from dependency_injector.providers import Callable
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
from sqlalchemy.orm import Session
from api.model.user import User
class UowBase:
def __init__(
self,
session_factory,
) -> None:
self.session = session_factory
async def get_all_users(self):
async with self.session as s:
query = select(User)
rr = await s.execute(query)
return rr.scalars().all()