aboutsummaryrefslogtreecommitdiff
path: root/tests/performance/perf_query.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/performance/perf_query.py')
-rw-r--r--tests/performance/perf_query.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/tests/performance/perf_query.py b/tests/performance/perf_query.py
index 12cb944..e534e9b 100644
--- a/tests/performance/perf_query.py
+++ b/tests/performance/perf_query.py
@@ -28,21 +28,19 @@ def timer(func):
def query_executor(query: str,
fetch_all: bool = True):
"""function to execute a query"""
- conn, _ = database_connector()
+ with database_connector() as conn:
+ with conn.cursor() as cursor:
+ cursor.execute(query)
- with conn:
- cursor = conn.cursor()
- cursor.execute(query)
-
- if fetch_all:
- return cursor.fetchall()
- return cursor.fetchone()
+ if fetch_all:
+ return cursor.fetchall()
+ return cursor.fetchone()
def fetch_probeset_query(dataset_name: str):
"""contains queries for datasets"""
- query = """SELECT * from ProbeSetData
+ query = f"""SELECT * from ProbeSetData
where StrainID in (4, 5, 6, 7, 8, 9, 10, 11, 12,
14, 15, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28,
29, 30, 31, 35, 36, 37, 39, 98, 99, 100, 103,
@@ -53,8 +51,8 @@ def fetch_probeset_query(dataset_name: str):
and id in (SELECT ProbeSetXRef.DataId
FROM (ProbeSet, ProbeSetXRef, ProbeSetFreeze)
WHERE ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id
- and ProbeSetFreeze.Name = '{}'
- and ProbeSet.Id = ProbeSetXRef.ProbeSetId)""".format(dataset_name)
+ and ProbeSetFreeze.Name = '{dataset_name}'
+ and ProbeSet.Id = ProbeSetXRef.ProbeSetId)"""
return query