delete item interactivity
This commit is contained in:
@ -45,6 +45,14 @@ def add_item():
|
||||
# item not valid or can't be parsed
|
||||
return jsonify({'status': 1}), 400
|
||||
|
||||
@app.route('/delete', methods=['POST'])
|
||||
def del_item():
|
||||
print("deleting item")
|
||||
data = request.get_json()
|
||||
uuid = data.get('uuid')
|
||||
delete_item(uuid)
|
||||
return jsonify({'deleted': uuid}), 200
|
||||
|
||||
@app.route('/datahistory',methods = ['GET'])
|
||||
def data_history_request():
|
||||
if request.method == 'GET':
|
||||
|
20
src/db.py
20
src/db.py
@ -122,6 +122,26 @@ def check_exist(itemid, skuid):
|
||||
else:
|
||||
return True
|
||||
|
||||
def delete_item(uuid):
|
||||
'''
|
||||
delete item and its history from database
|
||||
'''
|
||||
connection = connect_db()
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("""
|
||||
DELETE
|
||||
FROM history
|
||||
WHERE uuid = %s
|
||||
""", (uuid,))
|
||||
cursor.execute("""
|
||||
DELETE
|
||||
FROM history
|
||||
WHERE uuid = %s
|
||||
""", (uuid,))
|
||||
cursor.close()
|
||||
connection.commit()
|
||||
connection.close()
|
||||
|
||||
|
||||
def export_csv():
|
||||
'''join item and history data from database and export it in ./output.csv'''
|
||||
|
Reference in New Issue
Block a user