From 61f1c8371df75bfe05e2166abfcbd0adc3dbf437 Mon Sep 17 00:00:00 2001 From: ManuelW Date: Sat, 11 May 2024 10:13:00 +0200 Subject: [PATCH] DB config --- insertLoading.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/insertLoading.py b/insertLoading.py index 8544c8c..15b40c8 100644 --- a/insertLoading.py +++ b/insertLoading.py @@ -20,16 +20,17 @@ except: ## ### auf neue Files überwachen def main(): + global cursor try: db = sqlite3.connect(db_file) cursor = db.cursor() print("Connected to SQLite") - updateLast(cursor) + updateLast() db.commit() print("Data updated successfully into bike_loading table") - insertNew(cursor) + insertNew() db.commit() print("Data inserted successfully into bike_drives table") cursor.close() @@ -42,8 +43,8 @@ def main(): print("The SQLite connection is closed") -def updateLast(cursor): - global watt +def updateLast(): + global cursor, watt ## hole letztes Ladungs-Datum sql = ''' @@ -88,8 +89,8 @@ def updateLast(cursor): cursor.execute(sql, data) -def insertNew(cursor): - global loading +def insertNew(): + global cursor, loading date = datetime.today().strftime('%Y-%m-%d %H:%M:%S') data = (date, loading)