aboutsummaryrefslogtreecommitdiff
path: root/uploader
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-06-02 12:24:33 -0500
committerFrederick Muriuki Muriithi2025-06-02 12:31:54 -0500
commite3e097af4b92173e2bcb4771ccd1360fbe0e8cf6 (patch)
treeadfdac0260b0fd3c8e9fb69ece7d3b431b6f230b /uploader
parent78734ae46a39189e51105807fdfcc33a4320c514 (diff)
downloadgn-uploader-e3e097af4b92173e2bcb4771ccd1360fbe0e8cf6.tar.gz
Parametrize the "DataId" column for different tables.
Diffstat (limited to 'uploader')
-rw-r--r--uploader/phenotypes/models.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py
index 3e749c0..eb926d8 100644
--- a/uploader/phenotypes/models.py
+++ b/uploader/phenotypes/models.py
@@ -327,9 +327,12 @@ def save_phenotypes_data(
) -> tuple[dict, ...]:
"""Save new phenotypes data into the database."""
_table_details = {
- "PublishData": {"table": "PublishData", "valueCol": "value"},
- "PublishSE": {"table": "PublishSE", "valueCol": "error"},
- "NStrain": {"table": "PublishData", "valueCol": "count"}
+ "PublishData": {
+ "table": "PublishData", "valueCol": "value", "DataIdCol": "Id"},
+ "PublishSE": {
+ "table": "PublishSE", "valueCol": "error", "DataIdCol": "DataId"},
+ "NStrain": {
+ "table": "PublishData", "valueCol": "count", "DataIdCol": "DataId"}
}[table]
saved_data = tuple()
with conn.cursor(cursorclass=DictCursor) as cursor:
@@ -341,7 +344,7 @@ def save_phenotypes_data(
cursor.executemany(
(f"INSERT INTO {_table_details['table']}"
- f"(Id, StrainId, {_table_details['valueCol']}) "
+ f"({_table_details['DataIdCol']}, StrainId, {_table_details['valueCol']}) "
"VALUES "
f"(%(data_id)s, %(sample_id)s, %({_table_details['valueCol']})s) "
"RETURNING *"),