From 368b556a519a410ff5c9b3a97b6959a09bcbfe7d Mon Sep 17 00:00:00 2001 From: ManuelW Date: Sat, 11 May 2024 10:34:07 +0200 Subject: [PATCH] DB config --- insertLoading.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 = ?