当我输入数字的时候能查询并登陆,输入英文的时候就显示 no such column
import tkinter.messagebox
import tkinter as tk
import sqlite3class LoginPage:
def init(self,root):
self.win = root
self.win.geometry('210x80')
self.win.title('通讯录')
self.page = tk.Frame(win)
self.page.pack()
self.getusername = tk.StringVar()
self.password = tk.StringVar()
tk.Label(self.page, text='账户').grid(row=1, column=0) #提示用户
tk.Entry(self.page, textvariable=self.getusername, width=15).grid(row=1, column=1) #用户输入框
tk.Label(self.page, text='密码').grid(row=2, column=0) #提示密码
tk.Entry(self.page, textvariable=self.password, width=15).grid(row=2, column=1) #密码输入框
tk.Button(self.page, text='登 陆', command=self.login, width=12).grid(row=3, column=0) #点击登陆进行登陆
tk.Button(self.page, text='注 册',command=self.register, width=12).grid(row=3, column=1) #点击注册进行注册
def login(self): #登陆
conn = sqlite3.connect("D:\data.db")
cur = conn.cursor()
cur.execute("select * from login where username=" + self.getusername.get() )
conn.commit()
for row in cur:
if self.getusername.get() == row[0] and self.password.get() == row[1]:
print(row[0], row[1])
self.page.destroy()
Find(self.win)
else:
tk.messagebox.showwarning(title='错误', message='密码错误')
cur.close()
conn.close()
return self.getusername.get()
def register(self): #注册
self.page.destroy()
RegisterPage(self.win)