table adjusted
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
2024-01-31 13:43:21 +01:00
parent fd057e3415
commit 3852d78725
3 changed files with 10 additions and 11 deletions

View File

@ -128,6 +128,8 @@ def add_nutrition():
conn.commit()
return redirect(url_for('nutrition'))
except Exception as e:
return jsonify({"error": str(e)}), 500
finally:
if conn:
conn.close()
@ -146,13 +148,14 @@ def get_token():
@app.route('/get_database_entries')
@oidc.require_login
def get_database_entries():
try:
# Ersetzen Sie diese Werte mit Ihren Datenbank-Verbindungsinformationen
conn = psycopg2.connect()
cursor = conn.cursor()
with conn.cursor() as cursor:
cursor.execute("SELECT name, kcal, ew, fett, kh, bst, ca FROM nutrition_table")
cursor.execute("SELECT name, kcal, ew, fett, kh, bst, ca FROM nutrition_table ORDER BY name")
entries = cursor.fetchall()
# Umwandeln der Daten in ein JSON-freundliches Format