aboutsummaryrefslogtreecommitdiff
path: root/wqflask/db/webqtlDatabaseFunction.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-09-12 06:45:59 +0300
committerFrederick Muriuki Muriithi2022-09-12 06:45:59 +0300
commit18f4682a27630bd81eb0b1514476c2cf0f663a63 (patch)
tree38693342340285329cc1d8bdd2d9c9c4a20982d3 /wqflask/db/webqtlDatabaseFunction.py
parent228a5545adb47fee0de22e55536ee612aab9be66 (diff)
downloadgenenetwork2-18f4682a27630bd81eb0b1514476c2cf0f663a63.tar.gz
Check db resultset before indexing into it
The assumption that the resultset will never be empty was leading to a lot of errors.
Diffstat (limited to 'wqflask/db/webqtlDatabaseFunction.py')
-rw-r--r--wqflask/db/webqtlDatabaseFunction.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/wqflask/db/webqtlDatabaseFunction.py b/wqflask/db/webqtlDatabaseFunction.py
index 122c546f..878792b4 100644
--- a/wqflask/db/webqtlDatabaseFunction.py
+++ b/wqflask/db/webqtlDatabaseFunction.py
@@ -31,8 +31,9 @@ def retrieve_species(group):
cursor.execute(
"SELECT Species.Name FROM Species, InbredSet WHERE InbredSet.Name = %s AND InbredSet.SpeciesId = Species.Id",
(group,))
- return cursor.fetchone()[0]
- return result
+ results = cursor.fetchone()
+ if results and results[0]:
+ return results[0]
def retrieve_species_id(group):