From 517f68f61dc77301aa6aba5a8fb5ed80108ddb80 Mon Sep 17 00:00:00 2001 From: Davide Bongiovanni Date: Mon, 5 Jun 2017 00:33:11 +0200 Subject: [PATCH] Search is now case insensitive. Implemented get part info --- server.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/server.py b/server.py index 560a8d4..0b6819d 100644 --- a/server.py +++ b/server.py @@ -15,20 +15,28 @@ parts = {} def index(): return render_template('partsearch.html') +@app.route('/getpartinfo/') +def get_part_info(partID): + s = 'select * from parts where id = :id' + r = db_engine.execute(s, id=partID) + l = dict(r) + r.close() + return json.dumps(l) + @app.route('/query//') def query(filter, query): query = '%' + query + '%' s = 'select * from parts where ' if filter & (1 << 0) != 0: - s += 'type like :name or ' + s += 'LOWER(type) like LOWER(:name) or ' if filter & (1 << 1) != 0: - s += 'partno like :name or ' + s += 'LOWER(partno) like LOWER(:name) or ' if filter & (1 << 2) != 0: - s += 'partnoalt like :name or ' + s += 'LOWER(partnoalt) like LOWER(:name) or ' if filter & (1 << 3) != 0: - s += 'partnoalt2 like :name or ' + s += 'LOWER(partnoalt2) like LOWER(:name) or ' if filter & (1 << 4) != 0: - s += 'description like :name or ' + s += 'LOWER(description) like LOWER(:name) or ' s = s[:-4] + ';' s = text(s) r = db_engine.execute(s, name=query)