export data
This commit is contained in:
@ -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)
|
||||
|
14
src/db.py
14
src/db.py
@ -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()
|
||||
|
Reference in New Issue
Block a user