aboutsummaryrefslogtreecommitdiff
path: root/uploader
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-09-25 12:11:12 -0500
committerFrederick Muriuki Muriithi2024-09-25 12:11:58 -0500
commit4c9470646627a7b8d454d87984016cfa6c53059c (patch)
treef9f0a522d14ca906e590119df14417c8ae2c4efd /uploader
parent3e028bf0e9f8239b552bcd4b2d6133bb7965abd9 (diff)
downloadgn-uploader-4c9470646627a7b8d454d87984016cfa6c53059c.tar.gz
Provide missing database connection.
Diffstat (limited to 'uploader')
-rw-r--r--uploader/expression_data/dbinsert.py63
1 files changed, 32 insertions, 31 deletions
diff --git a/uploader/expression_data/dbinsert.py b/uploader/expression_data/dbinsert.py
index e746944..32ca359 100644
--- a/uploader/expression_data/dbinsert.py
+++ b/uploader/expression_data/dbinsert.py
@@ -319,37 +319,38 @@ def selected_keys(original: dict, keys: tuple) -> dict:
@require_login
def final_confirmation():
"Preview the data before triggering entry into the database"
- form = request.form
- try:
- assert form.get("filename"), "filename"
- assert form.get("filetype"), "filetype"
- assert form.get("species"), "species"
- assert form.get("genechipid"), "platform"
- assert form.get("studyid"), "study"
- assert form.get("datasetid"), "dataset"
-
- speciesid = form["species"]
- genechipid = form["genechipid"]
- studyid = form["studyid"]
- datasetid=form["datasetid"]
- return render_template(
- "final_confirmation.html", filename=form["filename"],
- filetype=form["filetype"], totallines=form["totallines"],
- species=speciesid, genechipid=genechipid, studyid=studyid,
- datasetid=datasetid, the_species=selected_keys(
- with_db_connection(lambda conn: species_by_id(conn, speciesid)),
- ("SpeciesName", "Name", "MenuName")),
- platform=selected_keys(
- platform_by_species_and_id(speciesid, genechipid),
- ("GeneChipName", "Name", "GeoPlatform", "Title", "GO_tree_value")),
- study=selected_keys(
- study_by_id(studyid), ("Name", "FullName", "ShortName")),
- dataset=selected_keys(
- dataset_by_id(datasetid),
- ("AvgMethodName", "Name", "Name2", "FullName", "ShortName",
- "DataScale")))
- except AssertionError as aserr:
- return render_error(f"Missing data: {aserr.args[0]}")
+ with database_connection(app.config["SQL_URI"]) as conn:
+ form = request.form
+ try:
+ assert form.get("filename"), "filename"
+ assert form.get("filetype"), "filetype"
+ assert form.get("species"), "species"
+ assert form.get("genechipid"), "platform"
+ assert form.get("studyid"), "study"
+ assert form.get("datasetid"), "dataset"
+
+ speciesid = form["species"]
+ genechipid = form["genechipid"]
+ studyid = form["studyid"]
+ datasetid=form["datasetid"]
+ return render_template(
+ "final_confirmation.html", filename=form["filename"],
+ filetype=form["filetype"], totallines=form["totallines"],
+ species=speciesid, genechipid=genechipid, studyid=studyid,
+ datasetid=datasetid, the_species=selected_keys(
+ with_db_connection(lambda conn: species_by_id(conn, speciesid)),
+ ("SpeciesName", "Name", "MenuName")),
+ platform=selected_keys(
+ platform_by_species_and_id(conn, speciesid, genechipid),
+ ("GeneChipName", "Name", "GeoPlatform", "Title", "GO_tree_value")),
+ study=selected_keys(
+ study_by_id(studyid), ("Name", "FullName", "ShortName")),
+ dataset=selected_keys(
+ dataset_by_id(datasetid),
+ ("AvgMethodName", "Name", "Name2", "FullName", "ShortName",
+ "DataScale")))
+ except AssertionError as aserr:
+ return render_error(f"Missing data: {aserr.args[0]}")
@dbinsertbp.route("/insert-data", methods=["POST"])
@require_login