aboutsummaryrefslogtreecommitdiff
path: root/qc_app/db
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-05-05 06:28:11 +0300
committerFrederick Muriuki Muriithi2024-05-05 06:28:11 +0300
commit9a54307817dda0d2f3da10e33b5189f199741c54 (patch)
tree0cdeeecc27f2988d1d6116a1d745eeaa2b5bf987 /qc_app/db
parentc316519b4b84f16234db2939a7c8544b33c0667d (diff)
downloadgn-uploader-9a54307817dda0d2f3da10e33b5189f199741c54.tar.gz
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.
Diffstat (limited to 'qc_app/db')
-rw-r--r--qc_app/db/populations.py10
1 files 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,