import mysql.connector
from Tkinter import *
def Db_Connection():
cnx = mysql.connector.connect (user='root', password='BlahBlahBlah',
host='127.0.0.1',
database='school')
Db_Connection()
______________________________________________________________________________
Class Login:
def __init__(self,master):
frame = Frame(master)
frame.pack()
self.Login = Button(frame, text="Login", command=self.login_db)
self.login.pack(side=LEFT)
self.quitButton = Button(frame, text="Quit", command=master.quit)
self.quitButton.pack(side=LEFT)
def login_db():
cursor.execute(SELECT * FROM teacher;)
root= Tk()
b = Login(root)
root.mainloop()
我得到的错误是教师不是有效的语法,即使我正在通过cursor.execute函数执行。单击登录按钮时,如何使程序执行数据库搜索。我更换了' cursor.execute'简单的打印(123)'它工作,它正在执行我正在努力的MySQL代码。