aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/authentication_tools.py
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/utility/authentication_tools.py')
-rw-r--r--wqflask/utility/authentication_tools.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/wqflask/utility/authentication_tools.py b/wqflask/utility/authentication_tools.py
index 96cc0b00..a8c03fe2 100644
--- a/wqflask/utility/authentication_tools.py
+++ b/wqflask/utility/authentication_tools.py
@@ -85,12 +85,13 @@ def add_new_resource(dataset, trait_id=None):
def get_group_code(dataset):
- results = g.db.execute(
- "SELECT InbredSetCode from InbredSet where Name='{}'".format(
- dataset.group.name)).fetchone()
- if results[0]:
- return results[0]
- else:
+ with database_connection() as conn, conn.cursor() as cursor:
+ cursor.execute(
+ "SELECT InbredSetCode FROM InbredSet WHERE Name=%s",
+ (dataset.group.name,)
+ )
+ if results := cursor.fetchone():
+ return results[0]
return ""