restore/export data popup, TODO: backend for restore data
This commit is contained in:
@ -144,6 +144,14 @@ def changeListContent():
|
||||
except:
|
||||
return str('error changing content'), 400
|
||||
|
||||
@app.route('/app/restore', methods=['POST'])
|
||||
def restore():
|
||||
data = request.get_json()
|
||||
d = data.get('data')
|
||||
# print(d)
|
||||
restore_db(d)
|
||||
return '1'
|
||||
|
||||
@app.route('/app/datahistory',methods = ['GET'])
|
||||
def data_history_request():
|
||||
if request.method == 'GET':
|
||||
|
11
src/db.py
11
src/db.py
@ -383,6 +383,17 @@ def fetch_all():
|
||||
connection.close()
|
||||
return results
|
||||
|
||||
def restore_db(data):
|
||||
tables_with_uuid = ["item", "itemlist"]
|
||||
tables = ["item", "itemlist", "listcontent", "history"]
|
||||
connection = connect_db()
|
||||
cursor = connection.cursor()
|
||||
for elem in data["item"]:
|
||||
print(elem)
|
||||
for table in tables:
|
||||
for elem in data[table]:
|
||||
print(elem)
|
||||
|
||||
def export_csv():
|
||||
'''join item and history data from database and export it in ./output.csv'''
|
||||
connection = connect_db()
|
||||
|
Reference in New Issue
Block a user