FEAT: Add an update query for updating the current station and status in the card if the logs is inserted successfully

This commit is contained in:
eloi 2025-03-30 14:48:32 +08:00
parent 0e1d2053a9
commit 13b0a47974

View File

@ -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')