db fix
This commit is contained in:
parent
24fb1c2941
commit
2228f0cfb5
@ -28,7 +28,7 @@ def calculate_nutrition(food, weight):
|
||||
|
||||
with conn.cursor() as cursor:
|
||||
# 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()
|
||||
|
||||
@ -115,8 +115,9 @@ def add_nutrition():
|
||||
try:
|
||||
conn = psycopg2.connect()
|
||||
with conn.cursor() as cursor:
|
||||
cursor.execute("INSERT INTO nutrition_table (name, kcal, ew, fett, kh, bst, ca) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
(food, kcal, ew, fett, kh, bst, ca))
|
||||
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))
|
||||
|
||||
|
||||
return redirect(url_for('nutrition'))
|
||||
finally:
|
||||
|
Loading…
x
Reference in New Issue
Block a user