diff --git a/src/app.py b/src/app.py index fca6747..024f83c 100644 --- a/src/app.py +++ b/src/app.py @@ -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': diff --git a/src/db.py b/src/db.py index 7d05fb9..bd4ed55 100644 --- a/src/db.py +++ b/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() diff --git a/web/app.html b/web/app.html index dada21f..6582290 100644 --- a/web/app.html +++ b/web/app.html @@ -39,8 +39,8 @@
-
- +
+
@@ -97,6 +97,27 @@ + + +