from typing import Optional from sqlalchemy import select from db.db_connection import async_session from db.models.experiment_parameters_model import ExperimentParameters class ExperimentParametersRepository: @staticmethod async def get_all() -> Optional[list[ExperimentParameters]]: async with async_session() as session: result = await session.execute(select(ExperimentParameters)) return result.scalars().all() @staticmethod async def get_by_id(id_: int) -> Optional[ExperimentParameters]: async with async_session() as session: result = session.get(ExperimentParameters, id_) return result @staticmethod async def create(outer_blades_count: int, outer_blades_length: float, outer_blades_angle: float, middle_blades_count: int, load_id: int, recycling_id: int, experiment_hash: str): new_data = ExperimentParameters( outer_blades_count=outer_blades_count, outer_blades_length=outer_blades_length, outer_blades_angle=outer_blades_angle, middle_blades_count=middle_blades_count, load_id=load_id, recycling_id=recycling_id, experiment_hash=experiment_hash ) async with async_session() as session: session.add(new_data) await session.commit()