aboutsummaryrefslogtreecommitdiff
path: root/qc_app/db/platforms.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/platforms.py
parent33e106334a212853842c30f8c595da1099c3d84e (diff)
downloadgn-uploader-cf8d133b110d87aed5cb6695711616625a6669fd.tar.gz
Create new ProbeSet study.
Diffstat (limited to 'qc_app/db/platforms.py')
-rw-r--r--qc_app/db/platforms.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/qc_app/db/platforms.py b/qc_app/db/platforms.py
new file mode 100644
index 0000000..cb527a7
--- /dev/null
+++ b/qc_app/db/platforms.py
@@ -0,0 +1,25 @@
+"""Handle db interactions for platforms."""
+from typing import Optional
+
+import MySQLdb as mdb
+from MySQLdb.cursors import DictCursor
+
+def platforms_by_species(
+ conn: mdb.Connection, speciesid: int) -> tuple[dict, ...]:
+ """Retrieve platforms by the species"""
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ cursor.execute("SELECT * FROM GeneChip WHERE SpeciesId=%s "
+ "ORDER BY GeneChipName ASC",
+ (speciesid,))
+ return tuple(dict(row) for row in cursor.fetchall())
+
+def platform_by_id(conn: mdb.Connection, platformid: int) -> Optional[dict]:
+ """Retrieve a platform by its ID"""
+ with conn.cursor(cursorclass=DictCursor) as cursor:
+ cursor.execute("SELECT * FROM GeneChip WHERE Id=%s",
+ (platformid,))
+ result = cursor.fetchone()
+ if bool(result):
+ return dict(result)
+
+ return None