#导入模块 从tkinter导入 * 从tkinter导入字体为tkfont 导入sqlite3 导入WebBrowser 从tkinter导入消息框 #Create根窗口 root = tk() #Inintalise连接到

问题描述 投票:0回答:1
这是一个学校的NEA项目,所以我的编程知识并不令人惊讶,很抱歉,如果它是明显的事情
    

在您的登录()函数中您通过:

cur.execute("SELECT * FROM Users WHERE Username =:Username",{"Username":str(Usernametxt,)}) userresult=cur.fetchall()
python database sqlite tkinter
1个回答
0
投票
但用户纳米特是一个tkentry小部件,直到您使用get()检索它之前,它不会容纳该值。搜索中的错误() 更正的版本:

def search(): userLogin = usernametxt.get() #create a variable to store the inputted value userPass = Passwordtxt.get() # same for password conn = sqlite3.connect(r"C:\Users\lukec\Desktop\Comp NEA\Data base for project.db") cur = conn.cursor() usernamesearch=cur.execute("SELECT * FROM Users WHERE Username = ?",(userLogin))#added get() here if usernamesearch == userLogin:#and user_found=True passwordsearch=cur.execute("SELECT * FROM Users WHERE Password = ?",(userPassword)) if passwordsearch == userPassword: pass_found=True
#功能链接主菜单页面
def登录(root,usernametxt,passwordTXT):
conn = sqlite3.connect(r“ c:\ users \ lukec \ desktop \ comp nea \ comp nea \ project.db”)
cur = conn.cursor()

user_found=False pass_found=False cur.execute("SELECT * FROM Users WHERE Username =:Username",{"Username":str(Usernametxt.get(),)})#added get() here userresult=cur.fetchall() if userresult: user_found=True else: user_found=False cur.execute("SELECT * FROM Users WHERE Password =:Password",{"Password":str(Passwordtxt.get(),)})#and here passresult=cur.fetchall() if passresult: pass_found=True else: pass_found=False if user_found == True and pass_found== True: messagebox.showinfo(title="login Message",message="Login Failed, Incorect Username or Password")
我希望这能解决问题!

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.