about summary refs log tree commit diff
path: root/uploader/genotypes/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/genotypes/models.py')
-rw-r--r--uploader/genotypes/models.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/uploader/genotypes/models.py b/uploader/genotypes/models.py
index 642caa6..29acd0b 100644
--- a/uploader/genotypes/models.py
+++ b/uploader/genotypes/models.py
@@ -41,12 +41,15 @@ def genotype_markers(
         return tuple(dict(row) for row in cursor.fetchall())
 
 
-def genotype_datasets(
+def genotype_dataset(
         conn: mdb.Connection,
         species_id: int,
         population_id: int
-) -> tuple[dict, ...]:
-    """Retrieve genotype datasets from the database."""
+) -> Optional[dict]:
+    """Retrieve genotype datasets from the database.
+
+    Apparently, you should only ever have one genotype dataset for a population.
+    """
     with conn.cursor(cursorclass=DictCursor) as cursor:
         cursor.execute(
             "SELECT gf.* FROM Species AS s INNER JOIN InbredSet AS iset "
@@ -54,4 +57,7 @@ def genotype_datasets(
             "ON iset.Id=gf.InbredSetId "
             "WHERE s.Id=%s AND iset.Id=%s",
             (species_id, population_id))
-        return tuple(dict(row) for row in cursor.fetchall())
+        result = cursor.fetchone()
+        if bool(result):
+            return dict(result)
+        return None