通过将变量username1
和password1
添加到数据库中,尝试创建一个显示新屏幕以注册新收银员的函数,但不断获取
sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.
谁能告诉我我要去哪里错了? 非常感谢
def register():
username = StringVar()
password = StringVar()
global Home
root.withdraw()
Home = Toplevel()
Home.title("The Belgium Fries Guys")
width = 500
height = 400
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x = (screen_width/2) - (width/2)
y = (screen_height/2) - (height/2)
root.resizable(0, 0)
Home.geometry("%dx%d+%d+%d" % (width, height, x, y))
lbl_home = Label(Home, text="Register New Cashier:", font=('Arial', 18)).grid()
btn_back = Button(Home, text='Back', command=Back).grid(pady=20, columnspan=3)
lbl_username1 = Label(Home, text = "Username:", font=('arial', 14), bd=15)
lbl_username1.grid(row=3, sticky="e")
lbl_password1 = Label(Home, text = "Password:", font=('arial', 14), bd=15)
lbl_password1.grid(row=4, sticky="e")
lbl_text = Label(Home)
username1 = Entry(Home, textvariable=username, font=(14))
username1.grid(row=3, column=1)
password1 = Entry(Home, textvariable=password, show="*", font=(14))
password1.grid(row=4, column=1)
global conn, cursor
conn = sqlite3.connect("cashier.db")
cursor = conn.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS `member` (mem_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, username TEXT, password TEXT)")
cursor.execute("insert into member(username, password) values (?, ?)",(username1, password1))
btn_register = Button(Form, text="Register", width=25, command=register)
btn_register.grid(pady=25, row=4, columnspan=3)
btn_register.bind('<Return>', register)