所以我試圖從我的 sqlite3 數據庫中檢索所有用戶 ID。Button我有一個 tkinter gui ,當用戶單擊按鈕時,系統會提示他們掃描標簽(rfid),可以進行簽入。我試圖在將標簽掃描到數據庫中的所有用戶 Uid 后比較標簽 ID,并檢查兩者是否匹配。如果它們匹配,我將嘗試打印“用戶已驗證”,如果標簽與表中的 UID 之一不匹配,我將嘗試打印“不存在用戶,拒絕”from tkinter import *import sqlite3 as sqlimport RPi.GPIO as GPIOfrom mfrc522 import SimpleMFRC522reader = SimpleMFRC522()global rglobal uid_tagdef chk(): Database = sql.connect('MedaDataBase.db') # cursor c= Database.cursor() #Query uid database c.execute("SELECT*, userID FROM Users ") #Fetch all uids from Database r= c.fetchall() if r: #Getting user uid from tag id,uid_tag = reader.read() print(uid_tag) checker()def checker(): global uid_tag global r for x in r: #If userId from tag is in the database if uid_tag == x: print("User Verified") else: print("Denied") Database.commit() Database.close()
添加回答
舉報
0/150
提交
取消