blob: 3a27706d948699b938eddf55c50d49e68d75da4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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())
|