From 13b0a47974a75303dcebb7804882b1771aa70884 Mon Sep 17 00:00:00 2001 From: eloi Date: Sun, 30 Mar 2025 14:48:32 +0800 Subject: [PATCH] FEAT: Add an update query for updating the current station and status in the card if the logs is inserted successfully --- tytocare_logs_extractor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tytocare_logs_extractor.py b/tytocare_logs_extractor.py index afbbe15..6bc0cc8 100644 --- a/tytocare_logs_extractor.py +++ b/tytocare_logs_extractor.py @@ -61,7 +61,7 @@ def main_loop(): global cursor if cursor: # Get all files in the source directory - files = glob.glob(SOURCE_DIR + '*.txt') + files = glob.glob(SOURCE_DIR + '**/*.txt', recursive=True) if files: for file in files: http_lines, enddate = extract_data_from_file(file) @@ -100,7 +100,12 @@ def main_loop(): # Insert data into the database insert_logpass = "INSERT INTO dbo.log_pass (account, cardno, line, sequence, station, machine, status, lastupdate, lastupdatedby) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)" + cursor.execute(insert_logpass, ('G5', cardno + '_1', '', '', stage, machine, database_status, log_pass_lastupdate, 'cats')) + + update_card = "UPDATE dbo.card SET curtstation = ?, status = ? WHERE cardno = ?" + cursor.execute(update_card, (stage, database_status, cardno + '_1')) + conn.commit() print('History inserted successfully')