Works with new database

master
Davide Bongiovanni 6 years ago
parent 5d90ad4aee
commit 9bf4943d3a

@ -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 != '')

Loading…
Cancel
Save