aboutsummaryrefslogtreecommitdiff
path: root/qc_app/db/tissues.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-01-18 05:52:52 +0300
committerFrederick Muriuki Muriithi2024-01-18 06:05:51 +0300
commitcf8d133b110d87aed5cb6695711616625a6669fd (patch)
tree2723f88cd1c1cd5b6c763c7030209d18975acffb /qc_app/db/tissues.py
parent33e106334a212853842c30f8c595da1099c3d84e (diff)
downloadgn-uploader-cf8d133b110d87aed5cb6695711616625a6669fd.tar.gz
Create new ProbeSet study.
Diffstat (limited to 'qc_app/db/tissues.py')
-rw-r--r--qc_app/db/tissues.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/qc_app/db/tissues.py b/qc_app/db/tissues.py
new file mode 100644
index 0000000..ebf24fd
--- /dev/null
+++ b/qc_app/db/tissues.py
@@ -0,0 +1,22 @@
+"""Handle db interactions for tissue."""
+from typing import Optional
+
+import MySQLdb as mdb
+from MySQLdb.cursors import DictCursor
+
+def all_tissues(conn: mdb.Connection) -> tuple[dict, ...]:
+ """All available tissue."""
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ cursor.execute("SELECT * FROM Tissue ORDER BY TissueName")
+ return tuple(dict(row) for row in cursor.fetchall())
+
+def tissue_by_id(conn: mdb.Connection, tissueid: int) -> Optional[dict]:
+ """Retrieve a tissue by its ID"""
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ cursor.execute("SELECT * FROM Tissue WHERE Id=%s",
+ (tissueid,))
+ result = cursor.fetchone()
+ if bool(result):
+ return dict(result)
+
+ return None