From 00608b18ef15e0a0efac683d183f47e954a93a70 Mon Sep 17 00:00:00 2001 From: Davide Bongiovanni Date: Tue, 6 Jun 2017 20:23:01 +0200 Subject: [PATCH] Hopefully fixed id problem --- server.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/server.py b/server.py index fc4ab54..13dbc41 100644 --- a/server.py +++ b/server.py @@ -62,6 +62,7 @@ def getfile(filename): @app.route('/parts/alter/', methods=['POST']) def alter(partID): + partID = int(partID) s = '' if partID < 0: # New entry @@ -74,6 +75,15 @@ def alter(partID): datasheet_file.save('/srv/datasheets/' + filename) else: datasheet_filename = '' + r = db_engine.execute(s, block=request.form['block'], + type=request.form['type'], + partno=request.form['partno'], + partnoalt=request.form['partnoalt'], + partnoalt2=request.form['partnoalt2'], + description=request.form['description'], + quantity=request.form['quantity'], + datasheet=datasheet_filename, + notes=request.form['notes']) else: # Modify entry r = db_engine.execute(text('select * from parts where id=:id;'), id=partID) @@ -92,16 +102,18 @@ def alter(partID): datasheet_filename = l['datasheet'] s += 'where id=:id;' s = text(s) + r = db_engine.execute(s, block=request.form['block'], + type=request.form['type'], + partno=request.form['partno'], + partnoalt=request.form['partnoalt'], + partnoalt2=request.form['partnoalt2'], + description=request.form['description'], + quantity=request.form['quantity'], + datasheet=datasheet_filename, + notes=request.form['notes'], + id=partID) + - r = db_engine.execute(s, block=request.form['block'], - type=request.form['type'], - partno=request.form['partno'], - partnoalt=request.form['partnoalt'], - partnoalt2=request.form['partnoalt2'], - description=request.form['description'], - quantity=request.form['quantity'], - datasheet=datasheet_filename, - notes=request.form['notes']) return '{"status":"ok"}' def connect(user, password, db, host='localhost', port=5432):