aboutsummaryrefslogtreecommitdiff
path: root/qc_app/dbinsert.py
diff options
context:
space:
mode:
Diffstat (limited to 'qc_app/dbinsert.py')
-rw-r--r--qc_app/dbinsert.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/qc_app/dbinsert.py b/qc_app/dbinsert.py
index 150127d..ef08423 100644
--- a/qc_app/dbinsert.py
+++ b/qc_app/dbinsert.py
@@ -156,25 +156,24 @@ def create_study():
with database_connection() as conn:
with conn.cursor(cursorclass=DictCursor) as cursor:
- cursor.execute("SELECT MAX(Id) AS last_id FROM ProbeFreeze")
- new_studyid = cursor.fetchone()["last_id"] + 1
values = (
- new_studyid, new_studyid, form["genechipid"],
- form["tissueid"], form["studyname"],
+ form["genechipid"],
+ form["tissueid"],
+ form["studyname"],
form.get("studyfullname", ""),
form.get("studyshortname", ""),
datetime.now().date().strftime("%Y-%m-%d"),
form["inbredsetid"])
query = (
"INSERT INTO ProbeFreeze("
- "Id, ProbeFreezeId, ChipId, TissueId, Name, FullName, "
- "ShortName, CreateTime, InbredSetId) "
- "VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s)")
+ "ChipId, TissueId, Name, FullName, ShortName, CreateTime, "
+ "InbredSetId"
+ ") VALUES (%s, %s, %s, %s, %s, %s, %s)")
cursor.execute(query, values)
- lastrowid = cursor.lastrowid
+ new_studyid = cursor.lastrowid
cursor.execute(
"UPDATE ProbeFreeze SET ProbeFreezeId=%s WHERE Id=%s",
- (lastrowid, lastrowid))
+ (new_studyid, new_studyid))
flash("Study created successfully", "alert-success")
return render_template(
"continue_from_create_study.html",
@@ -266,10 +265,8 @@ def create_dataset():
flash("A dataset with that name already exists.",
"alert-error")
return redirect(url_for("dbinsert.select_dataset"), code=307)
- cursor.execute("SELECT MAX(Id) AS last_id FROM ProbeSetFreeze")
- new_datasetid = cursor.fetchone()["last_id"] + 1
values = (
- new_datasetid, form["studyid"], form["avgid"],
+ form["studyid"], form["avgid"],
datasetname, form["datasetname2"],
form["datasetfullname"], form["datasetshortname"],
datetime.now().date().strftime("%Y-%m-%d"),
@@ -277,12 +274,13 @@ def create_dataset():
"williamslab", form["datasetdatascale"])
query = (
"INSERT INTO ProbeSetFreeze("
- "Id, ProbeFreezeId, AvgID, Name, Name2, FullName, "
+ "ProbeFreezeId, AvgID, Name, Name2, FullName, "
"ShortName, CreateTime, OrderList, public, "
"confidentiality, AuthorisedUsers, DataScale) "
"VALUES"
- "(%s, %s, %s, %s, %s, %s, %s, %s, NULL, %s, %s, %s, %s)")
+ "(%s, %s, %s, %s, %s, %s, %s, NULL, %s, %s, %s, %s)")
cursor.execute(query, values)
+ new_datasetid = cursor.lastrowid
return render_template(
"continue_from_create_dataset.html",
filename=form["filename"], filetype=form["filetype"],