27 lines
954 B
Python
27 lines
954 B
Python
from dbapi.repositories.utils import DatabaseInterfasesMixin
|
|
from sqlalchemy import insert
|
|
from dbapi.tables import approach
|
|
|
|
|
|
class ApproachRepository(DatabaseInterfasesMixin):
|
|
"""Approach table repository"""
|
|
|
|
def create_approach(self, exercise_pk: int, weight: float, reps: int) -> int:
|
|
"""Method for creating new instance of approach table
|
|
|
|
Args:
|
|
exercise_pk: Primary key of an associated exercise
|
|
weight: Approach weight
|
|
reps: Amount of reps in approach
|
|
|
|
Returns:
|
|
Primary key of created exercise entry
|
|
"""
|
|
new_instance_statement = insert(approach).values(
|
|
Exercise=exercise_pk, Weight=weight, Reps=reps
|
|
)
|
|
with self.engine.connect() as conn:
|
|
result = conn.execute(new_instance_statement)
|
|
inserted_entry_pk: int = result.inserted_primary_key[0]
|
|
conn.commit()
|
|
return inserted_entry_pk
|