PIbd-42_SSPR/db/repositories/experiment_data_repos.py

25 lines
815 B
Python

from typing import Sequence
from sqlalchemy.future import select
from db.models.experiment_data_model import ExperimentData
from db.postgres_db_connection import async_session_postgres
async def get_exp_data_by_file_id(file_id: str) -> Sequence[ExperimentData]:
async with async_session_postgres() as session:
result = await session.execute(
select(ExperimentData).where(ExperimentData.file_id == file_id)
)
return result.scalars().all()
async def get_all_exp_data(page: int, page_size: int) -> Sequence[ExperimentData]:
async with async_session_postgres() as session:
offset = (page - 1) * page_size
result = await session.execute(
select(ExperimentData).offset(offset).limit(page_size)
)
return result.scalars().all()