Search is now case insensitive. Implemented get part info

pull/3/head
Davide Bongiovanni 8 years ago
parent 47687905fa
commit 517f68f61d

@ -15,20 +15,28 @@ parts = {}
def index(): def index():
return render_template('partsearch.html') return render_template('partsearch.html')
@app.route('/getpartinfo/<partID>')
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/<filter>/<query>') @app.route('/query/<filter>/<query>')
def query(filter, query): def query(filter, query):
query = '%' + query + '%' query = '%' + query + '%'
s = 'select * from parts where ' s = 'select * from parts where '
if filter & (1 << 0) != 0: if filter & (1 << 0) != 0:
s += 'type like :name or ' s += 'LOWER(type) like LOWER(:name) or '
if filter & (1 << 1) != 0: if filter & (1 << 1) != 0:
s += 'partno like :name or ' s += 'LOWER(partno) like LOWER(:name) or '
if filter & (1 << 2) != 0: if filter & (1 << 2) != 0:
s += 'partnoalt like :name or ' s += 'LOWER(partnoalt) like LOWER(:name) or '
if filter & (1 << 3) != 0: if filter & (1 << 3) != 0:
s += 'partnoalt2 like :name or ' s += 'LOWER(partnoalt2) like LOWER(:name) or '
if filter & (1 << 4) != 0: if filter & (1 << 4) != 0:
s += 'description like :name or ' s += 'LOWER(description) like LOWER(:name) or '
s = s[:-4] + ';' s = s[:-4] + ';'
s = text(s) s = text(s)
r = db_engine.execute(s, name=query) r = db_engine.execute(s, name=query)

Loading…
Cancel
Save