diff options
author | Frederick Muriuki Muriithi | 2025-06-09 12:59:33 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-06-09 12:59:33 -0500 |
commit | a952dc61fb2961faa2a1107a2ec92370f10b60cd (patch) | |
tree | 661aa59a143e8e592a99bec3bcafa1a971406157 | |
parent | e58e29a4aefb0426fc61f9f6b3b9a824fb020279 (diff) | |
download | gn-uploader-a952dc61fb2961faa2a1107a2ec92370f10b60cd.tar.gz |
Fix return: Don't use `RETURNING *`.
Fetching the results of the insert query with `RETURNING *` does not
work as expected with MySQLdb. This commit, thus, returns the
explicitly computed values instead.
-rw-r--r-- | scripts/load_phenotypes_to_db.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/scripts/load_phenotypes_to_db.py b/scripts/load_phenotypes_to_db.py index 4b6bc9a..360cfbb 100644 --- a/scripts/load_phenotypes_to_db.py +++ b/scripts/load_phenotypes_to_db.py @@ -212,6 +212,8 @@ def cross_reference_phenotypes_publications_and_data( with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute("SELECT MAX(Id) CurrentMaxId FROM PublishXRef") _nextid = int(cursor.fetchone()["CurrentMaxId"]) + 1 + _params = tuple({**row, "xref_id": _id} + for _id, row in enumerate(xref_data, start=_nextid)) cursor.executemany( ("INSERT INTO PublishXRef(" "Id, InbredSetId, PhenotypeId, PublicationId, DataId, comments" @@ -219,11 +221,9 @@ def cross_reference_phenotypes_publications_and_data( "VALUES (" "%(xref_id)s, %(population_id)s, %(phenotype_id)s, " "%(publication_id)s, %(data_id)s, 'Upload of new data.'" - ") " - "RETURNING *"), - tuple({**row, "xref_id": _id} - for _id, row in enumerate(xref_data, start=_nextid))) - return tuple(dict(row) for row in cursor.fetchall()) + ")"), + _params) + return _params return tuple() |