From 9a54307817dda0d2f3da10e33b5189f199741c54 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Sun, 5 May 2024 06:28:11 +0300 Subject: Provide default for InbredSetId The `InbredSetId` field in the `InbredSet` table in MariaDB is in some instances a required field, so we need to provide a value. This value should be the same as that for the `Id` field, that we do not previously know. This commit provides a value of zero (0) as the default. This value is subsequently updated to be same as that of the `Id` field. --- qc_app/db/populations.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/qc_app/db/populations.py b/qc_app/db/populations.py index 48ead2e..4485e52 100644 --- a/qc_app/db/populations.py +++ b/qc_app/db/populations.py @@ -31,18 +31,20 @@ def save_population(conn: mdb.Connection, population_details: dict) -> dict: with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute( "INSERT INTO InbredSet(" - "InbredSetName, Name, SpeciesId, FullName, MenuOrderId, Description" + "InbredSetId, InbredSetName, Name, SpeciesId, FullName, " + "MenuOrderId, Description" ") " "VALUES (" - "%(InbredSetName)s, %(Name)s, %(SpeciesId)s, %(FullName)s, " - "%(MenuOrderId)s, %(Description)s" + "%(InbredSetId)s, %(InbredSetName)s, %(Name)s, %(SpeciesId)s, " + "%(FullName)s, %(MenuOrderId)s, %(Description)s" ")", { "MenuOrderId": 0, + "InbredSetId": 0, **population_details }) new_id = cursor.lastrowid - cursor.execute("UPDATE InbredSet SET InbredSetId=%s WHERE Id=%s" + cursor.execute("UPDATE InbredSet SET InbredSetId=%s WHERE Id=%s", (new_id, new_id)) return { **population_details, -- cgit v1.2.3