所以我試圖從我的 sqlite3 數(shù)據(jù)庫(kù)中檢索所有用戶 ID。Button我有一個(gè) tkinter gui ,當(dāng)用戶單擊按鈕時(shí),系統(tǒng)會(huì)提示他們掃描標(biāo)簽(rfid),可以進(jìn)行簽入。我試圖在將標(biāo)簽掃描到數(shù)據(jù)庫(kù)中的所有用戶 Uid 后比較標(biāo)簽 ID,并檢查兩者是否匹配。如果它們匹配,我將嘗試打印“用戶已驗(yàn)證”,如果標(biāo)簽與表中的 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()
添加回答
舉報(bào)
0/150
提交
取消