【发布时间】:2015-04-12 05:26:39
【问题描述】:
我正在尝试在表中搜索用户名,然后找到该用户的密码并根据输入检查它到目前为止我有...
def check():
username = logEntry.get()
password = passEntry.get()
curs.execute("SELECT * FROM logins WHERE username = VALUES (?);", (username))
userExists = curs.fetchone()
if userExists:
curs.execute("SELECT * FROM logins WHERE password = VALUES (?);",(password))
passExists = curs.fetchone()
if passExists:
controller.show_frame(look)
else:
errorLabel.place(x=0, y=0)
logButton = tk.Button(self, text="Login", command=check)
logButton.place(x=320, y=120)
regButton = tk.Button(self, text="Registration For New Users",
command=lambda: controller.show_frame(Register))
regButton.place(x=110, y=120)
任何帮助或建议将不胜感激:)
更新:我现在遇到了一个错误,指出列用户名不存在,这是我目前所拥有的。 @antti-haapala
def check():
username = logEntry.get()
password = passEntry.get()
cursor.execute("SELECT username, password" "FROM logins WHERE username = ?",(username))
resultrow = cursor.fetchone()
if resultrow is not None:
db_username, db_password = resultrow
if username == db_username and password == db_password:
controller.show_frame(look)
【问题讨论】:
-
你知道任何人都可以打开本地数据库并更改它吗?
-
怎么样?我对 python 和 sql 真的很陌生,所以非常感谢您的帮助
-
我想说的是,sqlite3 数据库只是一个文件,任何人都可以读取和写入,以访问您的系统。例如通过编写另一个 python 程序
-
该程序不会用于商业用途,所以这对我来说很好,谢谢您的信息