From cace7a50a45c6d227bce52569fcfc2944fbcbe92 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 8 Jan 2024 04:50:42 +0300 Subject: Extract common database functions into a separate package. --- qc_app/samples.py | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'qc_app/samples.py') diff --git a/qc_app/samples.py b/qc_app/samples.py index d27164e..107e889 100644 --- a/qc_app/samples.py +++ b/qc_app/samples.py @@ -48,35 +48,6 @@ def select_species(): flash("You need to select a species", "alert-error") return index_page -def save_population(conn: mdb.Connection, population_details: dict) -> int: - """Save the population details to the db.""" - with conn.cursor(cursorclass=DictCursor) as cursor: - cursor.execute("SELECT MAX(Id) AS last_id FROM InbredSet") - new_id = cursor.fetchone()["last_id"] + 1 - cursor.execute( - "INSERT INTO InbredSet(" - "Id, InbredSetId, InbredSetName, Name, SpeciesId, FullName, " - "MenuOrderId, Description" - ") " - "VALUES (" - "%(Id)s, %(InbredSetId)s, %(InbredSetName)s, %(Name)s, " - "%(SpeciesId)s, %(FullName)s, %(MenuOrderId)s, %(Description)s" - ")", - { - "Id": new_id, - "InbredSetId": new_id, - "MenuOrderId": 0, - **population_details - }) - return new_id - -def population_by_id(conn: mdb.Connection, population_id: int) -> dict: - """Get the grouping/population by id.""" - with conn.cursor(cursorclass=DictCursor) as cursor: - cursor.execute("SELECT * FROM InbredSet WHERE InbredSetId=%s", - (population_id,)) - return cursor.fetchone() - @samples.route("/upload/create-population", methods=["POST"]) def create_population(): """Create new grouping/population.""" -- cgit v1.2.3