From 9bf4943d3ab37143d72c0516526eda283dd3fad1 Mon Sep 17 00:00:00 2001 From: Davide Bongiovanni Date: Thu, 8 Nov 2018 21:26:52 +0100 Subject: [PATCH] Works with new database --- parts/server.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/parts/server.py b/parts/server.py index 58f7673..c3d5a30 100644 --- a/parts/server.py +++ b/parts/server.py @@ -54,14 +54,8 @@ def query(filter, query): query = '%' + query + '%' filter = int(filter) s = 'select * from parts where ' - if filter & (1 << 0) != 0: - s += 'LOWER(type) like LOWER(:name) or ' if filter & (1 << 1) != 0: s += 'LOWER(partno) like LOWER(:name) or ' - if filter & (1 << 2) != 0: - s += 'LOWER(partnoalt) like LOWER(:name) or ' - if filter & (1 << 3) != 0: - s += 'LOWER(partnoalt2) like LOWER(:name) or ' if filter & (1 << 4) != 0: s += 'LOWER(description) like LOWER(:name) or ' if filter & (1 << 5) != 0: @@ -134,7 +128,7 @@ def alter(partID): datasheet_filename = l[0]['datasheet'] s += 'where id=:id;' s = text(s) - r = db_engine.execute(s, block=request.form['block'], + r = db_engine.execute(s, location_id=request.form['block'], type=request.form['type'], partno=request.form['partno'], partnoalt=request.form['partnoalt'], @@ -174,7 +168,7 @@ def connect(user, password, db, host='localhost', port=5432): if __name__ == '__main__': with open('admin.json') as f: postgres_credentials = json.load(f) - db_engine, db_metadata = connect(postgres_credentials['username'], postgres_credentials['password'], 'parts') + db_engine, db_metadata = connect(postgres_credentials['username'], postgres_credentials['password'], 'parts_v2') parts = sqlalchemy.Table('parts', db_metadata) # Example query '''s = select([parts]).where(parts.c.notes != '')