diff --git a/src/Run.py b/src/Run.py index f9eaee9..2edb882 100644 --- a/src/Run.py +++ b/src/Run.py @@ -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: