aboutsummaryrefslogtreecommitdiff
path: root/qc_app/db/datasets.py
diff options
context:
space:
mode:
Diffstat (limited to 'qc_app/db/datasets.py')
-rw-r--r--qc_app/db/datasets.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/qc_app/db/datasets.py b/qc_app/db/datasets.py
index 448db18..b56dcf5 100644
--- a/qc_app/db/datasets.py
+++ b/qc_app/db/datasets.py
@@ -18,12 +18,12 @@ def geno_datasets_by_species_and_population(
{"sid": speciesid, "pid": populationid})
return tuple(dict(row) for row in cursor.fetchall())
-def geno_dataset_by_id(conn: mdb.Connection, dataset_id: int) -> dict:
+def geno_dataset_by_id(conn: mdb.Connection, dataset_id) -> Optional[dict]:
"""Retrieve genotype dataset by ID"""
with conn.cursor(cursorclass=DictCursor) as cursor:
- cursor.execute("SELECT * FROM GenoFreeze WHERE Id=%s",
- (dataset_id,))
- return dict(cursor.fetchone())
+ cursor.execute("SELECT * FROM GenoFreeze WHERE Id=%s", (dataset_id,))
+ _dataset = cursor.fetchone()
+ return dict(_dataset) if bool(_dataset) else None
def probeset_studies_by_species_and_population(
conn: mdb.Connection,
@@ -46,12 +46,12 @@ def probeset_datasets_by_study(conn: mdb.Connection,
(studyid,))
return tuple(dict(row) for row in cursor.fetchall())
-def probeset_study_by_id(conn: mdb.Connection, studyid: int) -> dict:
+def probeset_study_by_id(conn: mdb.Connection, studyid) -> Optional[dict]:
"""Retrieve ProbeSet study by ID"""
with conn.cursor(cursorclass=DictCursor) as cursor:
- cursor.execute("SELECT * FROM ProbeFreeze WHERE Id=%s",
- (studyid,))
- return dict(cursor.fetchone())
+ cursor.execute("SELECT * FROM ProbeFreeze WHERE Id=%s", (studyid,))
+ _study = cursor.fetchone()
+ return dict(_study) if bool(_study) else None
def probeset_create_study(conn: mdb.Connection,#pylint: disable=[too-many-arguments]
populationid: int,
@@ -120,12 +120,10 @@ def probeset_create_dataset(conn: mdb.Connection,#pylint: disable=[too-many-argu
dataset)
return {**dataset, "datasetid": cursor.lastrowid}
-def probeset_dataset_by_id(
- conn: mdb.Connection, datasetid: int) -> Optional[dict]:
+def probeset_dataset_by_id(conn: mdb.Connection, datasetid) -> Optional[dict]:
"""Fetch a ProbeSet dataset by its ID"""
with conn.cursor(cursorclass=DictCursor) as cursor:
- cursor.execute("SELECT * FROM ProbeSetFreeze WHERE Id=%s",
- (datasetid,))
+ cursor.execute("SELECT * FROM ProbeSetFreeze WHERE Id=%s", (datasetid,))
result = cursor.fetchone()
if bool(result):
return dict(result)