diff --git a/insertLoading.py b/insertLoading.py index 886684a..f40ee19 100644 --- a/insertLoading.py +++ b/insertLoading.py @@ -61,6 +61,12 @@ def updateLast(db, cursor): fahrten = 0 print("Anzahl:", len(rows)) + if len(rows) < 1: + cursor.close() + if db: + db.close() + print("The SQLite connection is closed") + exit(0) for row in rows: fahrten += 1 @@ -70,11 +76,12 @@ def updateLast(db, cursor): avg_speed = round(avg_speed / fahrten, 1) - data = (total_range, total_ascent, watt, fahrten, ins_id) + data = (total_range, total_ascent, avg_speed, watt, fahrten, ins_id) sql = ''' UPDATE bike_loading SET l_total_range = ?, l_total_ascent = ?, + l_avg_speed = ?, l_loaded_wh = ?, l_fahrten = ? WHERE id = ?