aboutsummaryrefslogtreecommitdiff
path: root/qc_app
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-02-02 05:17:50 +0300
committerFrederick Muriuki Muriithi2024-02-02 05:17:50 +0300
commit2b8fd63af18e70b4c8c20a34a6dfa041e8a832b9 (patch)
tree26276f08f6059e0b649a7ab55511622c93203a14 /qc_app
parent07deef46a3f3ba53cc632a9381fb25c55e1017b1 (diff)
downloadgn-uploader-2b8fd63af18e70b4c8c20a34a6dfa041e8a832b9.tar.gz
Bug: Specify DictCursor class to return dict-like result
Without specifying the `cursorclass`, the result is a tuple of the form: ((query_col01_val, query_col02_val, ...), ...) where the ellipsis specify the possibility of more than one of the previous form. We specify the DictCursor class instead so that the form changes to: ({query_col01_name: query_col01_val, ...}, ...) which allows us to pick the value we want with a string index.
Diffstat (limited to 'qc_app')
-rw-r--r--qc_app/db/populations.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/qc_app/db/populations.py b/qc_app/db/populations.py
index 0bcbe5d..06ae773 100644
--- a/qc_app/db/populations.py
+++ b/qc_app/db/populations.py
@@ -28,7 +28,7 @@ def populations_by_species(conn: mdb.Connection, speciesid) -> tuple:
def save_population(conn: mdb.Connection, population_details: dict) -> dict:
"""Save the population details to the db."""
- with conn.cursor() as cursor:
+ 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(