From 6222ebc5ca0fdeaac9ce7addd07ee4dd900a1afb Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 16 Jan 2024 12:48:43 +0300 Subject: UI: Create UI to select from existing genotype datasets. --- qc_app/db/datasets.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 qc_app/db/datasets.py (limited to 'qc_app/db/datasets.py') diff --git a/qc_app/db/datasets.py b/qc_app/db/datasets.py new file mode 100644 index 0000000..3a27706 --- /dev/null +++ b/qc_app/db/datasets.py @@ -0,0 +1,16 @@ +"""Functions for accessing the database relating to datasets.""" +import MySQLdb as mdb +from MySQLdb.cursors import DictCursor + +def geno_dataset_by_species_and_population( + conn: mdb.Connection, + speciesid: int, + populationid: int) -> tuple[dict, ...]: + """Retrieve all genotypes datasets by species and population""" + with conn.cursor(cursorclass=DictCursor) as cursor: + cursor.execute( + "SELECT gf.* FROM InbredSet AS iset INNER JOIN GenoFreeze AS gf " + "ON iset.InbredSetId=gf.InbredSetId " + "WHERE iset.SpeciesId=%(sid)s AND iset.InbredSetId=%(pid)s", + {"sid": speciesid, "pid": populationid}) + return tuple(dict(row) for row in cursor.fetchall()) -- cgit v1.2.3