aboutsummaryrefslogtreecommitdiff
path: root/gn3/db/phenotypes.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-07-21 08:37:13 +0300
committerFrederick Muriuki Muriithi2023-07-21 08:47:04 +0300
commit8222b37c9510a21ff40d2837d823b1cb50f70734 (patch)
treeb32b4c7774cfcfa0c5f38778343664f58ba71244 /gn3/db/phenotypes.py
parent8ab276d489c121c9f53bf9b55e20188acb744ea3 (diff)
downloadgenenetwork3-8222b37c9510a21ff40d2837d823b1cb50f70734.tar.gz
Update a Publication in the database.
Diffstat (limited to 'gn3/db/phenotypes.py')
-rw-r--r--gn3/db/phenotypes.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/gn3/db/phenotypes.py b/gn3/db/phenotypes.py
index 009dc1a..b42118a 100644
--- a/gn3/db/phenotypes.py
+++ b/gn3/db/phenotypes.py
@@ -151,3 +151,13 @@ def fetch_publication_by_pubmed_id(conn: DBConnection, pubmed_id: int) -> dict:
"WHERE PubMed_Id=%(pubmed_id)s"),
{"pubmed_id": pubmed_id})
return cursor.fetchone()
+
+def update_publication(conn, data=dict) -> int:
+ """Update the publication with the given data."""
+ updatable_cols = ", ".join(f"{publication_mapping[col]}=%({col})s"
+ for col in data
+ if col not in ("id_", "id"))
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ cursor.execute(
+ f"UPDATE Publication SET {updatable_cols} WHERE Id=%(id_)s", data)
+ return cursor.rowcount