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

21 lines
870 B
Python

from typing import Sequence
from sqlalchemy.future import select
from db.models.experiment_parameters_model import ExperimentParameters
from db.postgres_db_connection import async_session_postgres
async def get_exp_parameters_by_category(category_id: int) -> Sequence[ExperimentParameters]:
async with async_session_postgres() as session:
result = await session.execute(
select(ExperimentParameters).where(ExperimentParameters.experiment_category_id == category_id)
)
return result.scalars().all()
async def get_exp_parameters_by_exp_hash(exp_hash: str) -> Sequence[ExperimentParameters]:
async with async_session_postgres() as session:
result = await session.execute(
select(ExperimentParameters).where(ExperimentParameters.experiment_hash == exp_hash)
)
return result.scalars().all()