export data

This commit is contained in:
2024-02-23 21:57:18 +01:00
parent 3e92c644fd
commit bdcef0911d
6 changed files with 88 additions and 3 deletions

View File

@ -144,8 +144,6 @@ def changeListContent():
except:
return str('error changing content'), 400
@app.route('/app/datahistory',methods = ['GET'])
def data_history_request():
if request.method == 'GET':
@ -191,6 +189,9 @@ def data_list_request():
details = get_list(list_uuid)
return jsonify(details), 200
@app.route('/app/data-all', methods = ['GET'])
def data_request_all():
return jsonify(fetch_all()), 200
if __name__ == '__main__':
app.run(debug = True)

View File

@ -369,6 +369,20 @@ def change_list_description(uuid, description):
connection.commit()
connection.close()
def fetch_all():
tables = ["item", "itemlist", "listcontent", "history"]
results = []
connection = connect_db()
cursor = connection.cursor()
for table in tables:
query = f'SELECT * FROM {str(table)};'
cursor.execute(query)
results.append(cursor.fetchall())
cursor.close()
connection.commit()
connection.close()
return results
def export_csv():
'''join item and history data from database and export it in ./output.csv'''
connection = connect_db()