【发布时间】:2019-08-11 14:00:28
【问题描述】:
我需要我的程序从 Tkinter 窗口的输入字段中获取输入并通过数据库运行它们以使用户登录,但是,它说我的参数 0(用户名)存在绑定问题,并且我假设我的密码变量也会发生这种情况。
def loginfunc():
while True:
with sqlite3.connect('MyComputerScience.db') as db:
cursor = db.cursor()
find_user = ("SELECT * FROM users WHERE username = ? AND password = ?")
cursor.execute(find_user, (username, password))
results = cursor.fetchall()
if results:
for i in results:
print ("welcome "+i[1]+"")
break
else:
print ("Username or password incorrect")
login()
break
def login():
screen1 = Toplevel(screen)
screen1.title("Login")
screen1.geometry("300x250")
global username
global password
username = StringVar()
password = StringVar()
Label(screen1, text = "Please enter your username and password below: ").pack()
Label(screen1, text = "").pack()
Label(screen1, text = "Username: ").pack()
Entry(screen1, textvariable = username).pack()
Label(screen1, text = "").pack()
Label(screen1, text = "Password: ").pack()
Entry(screen1, textvariable = password).pack()
Label(screen1, text = "").pack()
Button(screen1, text = "Login", width = 10, height = 1, command=loginfunc).pack()
File "C:\Users\notmyname\Desktop\NEA PROPER.py", line 90, in loginfunc
cursor.execute(find_user, (username, password))
sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.
【问题讨论】: