18 lines
647 B
Python
18 lines
647 B
Python
from typing import List, Dict, Any
|
|
from app.core.database.connection import SQLiteExecutor
|
|
from app.core.dto.training import TrainingDTO
|
|
|
|
|
|
class TrainingOps:
|
|
def __init__(self, executor: SQLiteExecutor) -> None:
|
|
self._executor = executor
|
|
|
|
async def create(self, training: TrainingDTO) -> int:
|
|
query = "INSERT INTO trainings (date, trainer) VALUES (?, ?)"
|
|
return await self._executor.execute_mod_query(
|
|
query, (training.date, training.trainer)
|
|
)
|
|
|
|
async def list(self) -> List[Dict[str, Any]]:
|
|
query = "SELECT * FROM trainings"
|
|
return await self._executor.execute_query(query)
|