我正在尝试用rfid和密码来创建python智能锁,而不是常规的"1234",我在PyOTP Libray中使用Time。
目前,我一直在研究如何使用来自表用户的secret数据在if函数中分配secret变量值。
如何将secret值从users表分配给变量secret
IF函数
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 |
+----+--------------+-------------+------------------+---------------------+谢谢
发布于 2020-12-10 05:04:59
如果修改select语句,除了选择secret之外,还应该能够选择id。
print("Place card near scanner")
id, text = reader.read()
cursor.execute("SELECT id, secret FROM users WHERE rfid_uid="+str(id))
result = cursor.fetchone()
if cursor.rowcount >= 1:
print("Welcome\nType the code from your authenticator app")
secret = result[1]https://stackoverflow.com/questions/65228007
复制相似问题