aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/performance/timeit_gn2.py3
-rw-r--r--scripts/sampledata.py8
2 files changed, 7 insertions, 4 deletions
diff --git a/scripts/performance/timeit_gn2.py b/scripts/performance/timeit_gn2.py
index 1c64e22c..a3e1fb20 100644
--- a/scripts/performance/timeit_gn2.py
+++ b/scripts/performance/timeit_gn2.py
@@ -14,7 +14,7 @@ class UserSessionSimulator():
def dump_sample_data(dataset_name, trait_id):
- with database_connection() as conn, conn.cursor() as cursor:
+ with database_connection(get_setting("SQL_URI")) as conn, conn.cursor() as cursor:
sample_data = {"headers": ["Name", "Value", "SE"], "data": []}
with app.app_context():
@@ -47,6 +47,7 @@ print(dump_sample_data("HLCPublish", "10001"))
from flask import g
from wqflask import app
+from utility.tools import get_setting
from wqflask.database import database_connection
from wqflask.show_trait import show_trait
""",
diff --git a/scripts/sampledata.py b/scripts/sampledata.py
index 9e9733bf..34248823 100644
--- a/scripts/sampledata.py
+++ b/scripts/sampledata.py
@@ -17,6 +17,8 @@ from wqflask.show_trait import show_trait
from wqflask.database import database_connection
from wqflask.search_results import SearchResultPage
+from utility.tools import get_setting
+
class UserSessionSimulator():
def __init__(self, user_id):
@@ -35,7 +37,7 @@ def camel_case(string):
def dump_sample_data(dataset_name, trait_id):
"""Given a DATASET_NAME e.g. 'BXDPublish' and a TRAIT_ID
e.g. '10007', dump the sample data as json object"""
- with database_connection() as conn, conn.cursor() as cursor:
+ with database_connection(get_setting("SQL_URI")) as conn, conn.cursor() as cursor:
sample_data = {"headers": ["Name", "Value", "SE"], "data": []}
with app.app_context():
@@ -76,7 +78,7 @@ def fetch_all_traits(species, group, type_, dataset):
def get_trait_metadata(dataset_name, trait_id):
- with database_connection() as conn, conn.cursor() as cursor:
+ with database_connection(get_setting("SQL_URI")) as conn, conn.cursor() as cursor:
with app.app_context():
g.user_session = UserSessionSimulator(None)
data = show_trait.ShowTrait(
@@ -138,7 +140,7 @@ Dumping {dataset_name} into {sys.argv[1]}:
def main():
# Dump all sampledata into a given directory
- with database_connection() as conn:
+ with database_connection(get_setting("SQL_URI")) as conn:
for species, group in gen_dropdown_json(conn).get("datasets").items():
for group_name, type_ in group.items():
for dataset_type, datasets in type_.items():