|
|
@ -54,14 +54,8 @@ def query(filter, query):
|
|
|
|
query = '%' + query + '%'
|
|
|
|
query = '%' + query + '%'
|
|
|
|
filter = int(filter)
|
|
|
|
filter = int(filter)
|
|
|
|
s = 'select * from parts where '
|
|
|
|
s = 'select * from parts where '
|
|
|
|
if filter & (1 << 0) != 0:
|
|
|
|
|
|
|
|
s += 'LOWER(type) like LOWER(:name) or '
|
|
|
|
|
|
|
|
if filter & (1 << 1) != 0:
|
|
|
|
if filter & (1 << 1) != 0:
|
|
|
|
s += 'LOWER(partno) like LOWER(:name) or '
|
|
|
|
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:
|
|
|
|
if filter & (1 << 4) != 0:
|
|
|
|
s += 'LOWER(description) like LOWER(:name) or '
|
|
|
|
s += 'LOWER(description) like LOWER(:name) or '
|
|
|
|
if filter & (1 << 5) != 0:
|
|
|
|
if filter & (1 << 5) != 0:
|
|
|
@ -134,7 +128,7 @@ def alter(partID):
|
|
|
|
datasheet_filename = l[0]['datasheet']
|
|
|
|
datasheet_filename = l[0]['datasheet']
|
|
|
|
s += 'where id=:id;'
|
|
|
|
s += 'where id=:id;'
|
|
|
|
s = text(s)
|
|
|
|
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'],
|
|
|
|
type=request.form['type'],
|
|
|
|
partno=request.form['partno'],
|
|
|
|
partno=request.form['partno'],
|
|
|
|
partnoalt=request.form['partnoalt'],
|
|
|
|
partnoalt=request.form['partnoalt'],
|
|
|
@ -174,7 +168,7 @@ def connect(user, password, db, host='localhost', port=5432):
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
with open('admin.json') as f:
|
|
|
|
with open('admin.json') as f:
|
|
|
|
postgres_credentials = json.load(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)
|
|
|
|
parts = sqlalchemy.Table('parts', db_metadata)
|
|
|
|
# Example query
|
|
|
|
# Example query
|
|
|
|
'''s = select([parts]).where(parts.c.notes != '')
|
|
|
|
'''s = select([parts]).where(parts.c.notes != '')
|
|
|
|