diff options
author | Frederick Muriuki Muriithi | 2025-04-28 03:52:35 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-04-28 03:52:35 -0500 |
commit | 60c6f059c3f62807f1a4520e3a0a9af940ebe4af (patch) | |
tree | 49b4877b3c9c990ff9a7f82f9c97cfd922c2edfe /uploader | |
parent | 4a16f580a25aba122a4990a61e0e96f4692b833c (diff) | |
download | gn-uploader-60c6f059c3f62807f1a4520e3a0a9af940ebe4af.tar.gz |
Fetch a publication by its ID.
Diffstat (limited to 'uploader')
-rw-r--r-- | uploader/publications/models.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/uploader/publications/models.py b/uploader/publications/models.py index 6034c9e..22690f8 100644 --- a/uploader/publications/models.py +++ b/uploader/publications/models.py @@ -80,3 +80,11 @@ def fetch_publications(conn: Connection) -> Iterable[dict]: cursor.execute("SELECT * FROM Publication") for row in cursor.fetchall(): yield dict(row) + + +def fetch_publication_by_id(conn: Connection, publication_id: int) -> dict: + """Fetch a specific publication from the database.""" + with conn.cursor(cursorclass=DictCursor) as cursor: + cursor.execute("SELECT * FROM Publication WHERE Id=%s", + (publication_id,)) + return dict(cursor.fetchone()) |