diff options
author | zsloan | 2022-09-06 13:32:28 -0500 |
---|---|---|
committer | GitHub | 2022-09-06 13:32:28 -0500 |
commit | d8bc7067b717e0b680d98b7cfcbc26c758a109bf (patch) | |
tree | 571677761b3bb464b55bc19f208f135214321ad2 /wqflask/db/webqtlDatabaseFunction.py | |
parent | e0626f40d8fe4fa83daba52b82c1b459b34b1849 (diff) | |
parent | 363237f11b9eb14f52c4f0c43a931c99c827c496 (diff) | |
download | genenetwork2-d8bc7067b717e0b680d98b7cfcbc26c758a109bf.tar.gz |
Merge branch 'testing' into feature/generalize_tables
Diffstat (limited to 'wqflask/db/webqtlDatabaseFunction.py')
-rw-r--r-- | wqflask/db/webqtlDatabaseFunction.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/wqflask/db/webqtlDatabaseFunction.py b/wqflask/db/webqtlDatabaseFunction.py index 9ec650a4..122c546f 100644 --- a/wqflask/db/webqtlDatabaseFunction.py +++ b/wqflask/db/webqtlDatabaseFunction.py @@ -20,19 +20,23 @@ # # This module is used by GeneNetwork project (www.genenetwork.org) -from db.call import fetch1 +from wqflask.database import database_connection def retrieve_species(group): """Get the species of a group (e.g. returns string "mouse" on "BXD" """ - result = fetch1("select Species.Name from Species, InbredSet where InbredSet.Name = '%s' and InbredSet.SpeciesId = Species.Id" % ( - group), "/cross/" + group + ".json", lambda r: (r["species"],))[0] + with database_connection() as conn, conn.cursor() as cursor: + cursor.execute( + "SELECT Species.Name FROM Species, InbredSet WHERE InbredSet.Name = %s AND InbredSet.SpeciesId = Species.Id", + (group,)) + return cursor.fetchone()[0] return result def retrieve_species_id(group): - result = fetch1("select SpeciesId from InbredSet where Name = '%s'" % ( - group), "/cross/" + group + ".json", lambda r: (r["species_id"],))[0] - return result + with database_connection() as conn, conn.cursor() as cursor: + cursor.execute("SELECT SpeciesId FROM InbredSet WHERE Name = %s", + (group,)) + return cursor.fetchone()[0] |