Files
FastAPI_async/utils/db/db_execution.py
2025-09-26 10:47:57 +02:00

22 lines
611 B
Python

from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select
from models.execution.model_execution import ExecutionModel
class ExecutionQueryAsync:
def __init__(self, db: AsyncSession):
self.db = db
async def get_execution(self):
result = await self.db.execute(select(ExecutionModel))
rows = result.scalars().all()
return rows
async def get_execution_by_id(self, id):
stmt = select(ExecutionModel).where(ExecutionModel.id == id)
result = await self.db.execute(stmt)
rows = result.scalars().all()
return rows