This commit is contained in:
moerp 2024-01-30 15:29:46 +01:00
parent 24fb1c2941
commit 2228f0cfb5

View File

@ -28,7 +28,7 @@ def calculate_nutrition(food, weight):
with conn.cursor() as cursor: with conn.cursor() as cursor:
# Abfrage der Nährwertdaten aus der Datenbank # Abfrage der Nährwertdaten aus der Datenbank
cursor.execute('SELECT kcal, EW, Fett, KH, BST, CA FROM nutrition_table WHERE name = ?', (food,)) cursor.execute('SELECT kcal, EW, Fett, KH, BST, CA FROM nutrition_table WHERE name = %s', (food,))
result = cursor.fetchone() result = cursor.fetchone()
@ -115,8 +115,9 @@ def add_nutrition():
try: try:
conn = psycopg2.connect() conn = psycopg2.connect()
with conn.cursor() as cursor: with conn.cursor() as cursor:
cursor.execute("INSERT INTO nutrition_table (name, kcal, ew, fett, kh, bst, ca) VALUES (?, ?, ?, ?, ?, ?, ?)", cursor.execute("INSERT INTO nutrition_table (name, kcal, ew, fett, kh, bst, ca) VALUES (%s, %s, %s, %s, %s, %s, %s)",
(food, kcal, ew, fett, kh, bst, ca)) (food, kcal, ew, fett, kh, bst, ca))
return redirect(url_for('nutrition')) return redirect(url_for('nutrition'))
finally: finally: