diff options
author | Frederick Muriuki Muriithi | 2023-07-18 13:09:40 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-07-18 13:09:40 +0300 |
commit | 17b852784f5320cb6d51595029c124b10375e848 (patch) | |
tree | 9651f12dba386f1b526436ac136f3c75de71a1d1 | |
parent | 8a910ebe01ed46ef374daa091e18a65a855070c2 (diff) | |
download | genenetwork3-17b852784f5320cb6d51595029c124b10375e848.tar.gz |
Fetch a single publication by `PublicationId`
-rw-r--r-- | gn3/db/phenotypes.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gn3/db/phenotypes.py b/gn3/db/phenotypes.py index 54630b4..220284d 100644 --- a/gn3/db/phenotypes.py +++ b/gn3/db/phenotypes.py @@ -194,3 +194,13 @@ def fetch_metadata(conn: DBConnection, phenotype_id: int) -> dict: "WHERE Id=%(phenotype_id)s"), {"phenotype_id": phenotype_id}) return cursor.fetchone() + +def fetch_publication(conn: DBConnection, publication_id: int) -> dict: + """Fetch the publication by its ID.""" + with conn.cursor(cursorclass=DictCursor) as cursor: + cols = ', '.join(_mapping_to_query_columns_(publication_mapping)) + cursor.execute( + (f"SELECT Id as id, {cols} FROM Publication " + "WHERE Id=%(publication_id)s"), + {"publication_id": publication_id}) + return cursor.fetchone() |