diff options
author | Frederick Muriuki Muriithi | 2022-09-12 06:45:59 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-09-12 06:45:59 +0300 |
commit | 18f4682a27630bd81eb0b1514476c2cf0f663a63 (patch) | |
tree | 38693342340285329cc1d8bdd2d9c9c4a20982d3 /wqflask/db | |
parent | 228a5545adb47fee0de22e55536ee612aab9be66 (diff) | |
download | genenetwork2-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')
-rw-r--r-- | wqflask/db/webqtlDatabaseFunction.py | 5 |
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): |