aboutsummaryrefslogtreecommitdiff
path: root/uploader/phenotypes/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/phenotypes/models.py')
-rw-r--r--uploader/phenotypes/models.py18
1 files changed, 3 insertions, 15 deletions
diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py
index f4d3529..7861427 100644
--- a/uploader/phenotypes/models.py
+++ b/uploader/phenotypes/models.py
@@ -324,7 +324,7 @@ def save_phenotypes_data(
conn: mdb.Connection,
table: str,
data: Iterable[dict]
-) -> tuple[dict, ...]:
+) -> int:
"""Save new phenotypes data into the database."""
_table_details = {
"PublishData": {
@@ -334,7 +334,6 @@ def save_phenotypes_data(
"NStrain": {
"table": "PublishData", "valueCol": "count", "DataIdCol": "DataId"}
}[table]
- saved_data = tuple()
with conn.cursor(cursorclass=DictCursor) as cursor:
_count = 0
while True:
@@ -348,21 +347,10 @@ def save_phenotypes_data(
(f"INSERT INTO {_table_details['table']}"
f"({_table_details['DataIdCol']}, StrainId, {_table_details['valueCol']}) "
"VALUES "
- f"(%(data_id)s, %(sample_id)s, %({_table_details['valueCol']})s) "
- "RETURNING *"),
+ f"(%(data_id)s, %(sample_id)s, %({_table_details['valueCol']})s) "),
tuple(batch))
-
- paramstr = ", ".join(["(%s, %s)"] * len(batch))
- cursor.execute(f"SELECT * FROM {_table_details['table']} "
- f"WHERE ({_table_details['DataIdCol']}, StrainId) "
- f"IN ({paramstr})",
- tuple(single for items in
- ((item["data_id"], item["sample_id"])
- for item in batch)
- for single in items))
- saved_data = saved_data + tuple(dict(row) for row in cursor.fetchall())
_count = _count + len(batch)
logger.debug("Saved a total of %s data rows", _count)
- return saved_data
+ return _count