我正在尝试使用 rfid 和密码而不是常规的“1234”创建一个 python 智能锁,我将 Time OTP 与PyOTP Libray一起使用。
目前,我不知道如何使用来自表用户secret
的数据在 if 函数中分配变量值。secret
如何将 secret
用户表中的值分配给变量secret
如果函数
print("Place card near scanner")
id, text = reader.read()
cursor.execute("Select id From users Where rfid_uid="+str(id))
result = cursor.fetchone()
if cursor.rowcount > = 1:
print("Welcome\nType the code from your authenticator app")
secret = ('''The data from "secret" in users table''')
用户表
+----+--------------+-------------+------------------+---------------------+
| id | rfid_uid | name | secret | created |
+----+--------------+-------------+------------------+---------------------+
| 1 | 939940479059 | Blue Dongle | LONGSTRINGOFCODE | 2020-12-10 09:07:34 |
+----+--------------+-------------+------------------+---------------------+
谢谢你