Remove all old code, referencing database integration
This commit is contained in:
parent
061fcb45f5
commit
b5e207fc57
8 changed files with 0 additions and 98 deletions
|
|
@ -1,15 +0,0 @@
|
||||||
from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine
|
|
||||||
from dbapi.tables import metadata_obj
|
|
||||||
|
|
||||||
|
|
||||||
class FitnessDatabseMigrator:
|
|
||||||
"""Class for performing management operations with database"""
|
|
||||||
|
|
||||||
def __init__(self, async_engine: AsyncEngine) -> None:
|
|
||||||
self.engine = async_engine
|
|
||||||
|
|
||||||
async def reset_database(self):
|
|
||||||
"""Method for dropping all tables and create them from tables metadata"""
|
|
||||||
async with self.engine.begin() as conn:
|
|
||||||
await conn.run_sync(metadata_obj.drop_all)
|
|
||||||
await conn.run_sync(metadata_obj.create_all)
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
from sqlalchemy import insert
|
|
||||||
from dbapi.repositories.utils import DatabaseInterfasesMixin
|
|
||||||
from dbapi.tables import exercise
|
|
||||||
|
|
||||||
|
|
||||||
class ExerciseRepository(DatabaseInterfasesMixin):
|
|
||||||
"""Exercise table repository"""
|
|
||||||
|
|
||||||
def create_exercise(self, training_pk: int, exercise_name: str) -> int:
|
|
||||||
"""Method for creating new instance of exercise table
|
|
||||||
Args:
|
|
||||||
training_pk: Primary key of associated training instance
|
|
||||||
exercise_name: Name of an exercise
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Primary key of created exercise entry
|
|
||||||
"""
|
|
||||||
new_instance_statement = insert(exercise).values(
|
|
||||||
Training=training_pk, Name=exercise_name
|
|
||||||
)
|
|
||||||
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
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
from sqlalchemy import insert
|
|
||||||
from datetime import date
|
|
||||||
from dbapi.repositories.utils import DatabaseInterfasesMixin
|
|
||||||
from dbapi.tables import training
|
|
||||||
|
|
||||||
|
|
||||||
class TrainingRepository(DatabaseInterfasesMixin):
|
|
||||||
"""Training table repository"""
|
|
||||||
|
|
||||||
def create_training(self, date: date) -> int:
|
|
||||||
"""Method for creating new instance of training
|
|
||||||
Args:
|
|
||||||
date: date of a training
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Primary key of created training entry
|
|
||||||
"""
|
|
||||||
new_instance_statement = insert(training).values(Date=date)
|
|
||||||
with self.engine.connect() as conn:
|
|
||||||
result = conn.execute(new_instance_statement)
|
|
||||||
inerted_entry_pk: int = result.inserted_primary_key[0]
|
|
||||||
conn.commit()
|
|
||||||
return inerted_entry_pk
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
from sqlalchemy import Engine
|
|
||||||
|
|
||||||
|
|
||||||
class DatabaseInterfasesMixin:
|
|
||||||
"""Mixin for interfaces, that works with database"""
|
|
||||||
|
|
||||||
def __init__(self, engine: Engine) -> None:
|
|
||||||
self.engine: Engine = engine
|
|
||||||
Loading…
Reference in a new issue