DB config

This commit is contained in:
Manuel Weiser 2024-05-11 10:13:00 +02:00
parent 592866e27c
commit 61f1c8371d

View File

@ -20,16 +20,17 @@ except:
## ##
### auf neue Files überwachen ### auf neue Files überwachen
def main(): def main():
global cursor
try: try:
db = sqlite3.connect(db_file) db = sqlite3.connect(db_file)
cursor = db.cursor() cursor = db.cursor()
print("Connected to SQLite") print("Connected to SQLite")
updateLast(cursor) updateLast()
db.commit() db.commit()
print("Data updated successfully into bike_loading table") print("Data updated successfully into bike_loading table")
insertNew(cursor) insertNew()
db.commit() db.commit()
print("Data inserted successfully into bike_drives table") print("Data inserted successfully into bike_drives table")
cursor.close() cursor.close()
@ -42,8 +43,8 @@ def main():
print("The SQLite connection is closed") print("The SQLite connection is closed")
def updateLast(cursor): def updateLast():
global watt global cursor, watt
## hole letztes Ladungs-Datum ## hole letztes Ladungs-Datum
sql = ''' sql = '''
@ -88,8 +89,8 @@ def updateLast(cursor):
cursor.execute(sql, data) cursor.execute(sql, data)
def insertNew(cursor): def insertNew():
global loading global cursor, loading
date = datetime.today().strftime('%Y-%m-%d %H:%M:%S') date = datetime.today().strftime('%Y-%m-%d %H:%M:%S')
data = (date, loading) data = (date, loading)