尝试在tkinter GUI上显示数据库数据时当前收到错误。{但是我不知道怎么去修正错误。在
以下是我返回所有信息的课程:
class Database:
def __init__(self, master):
self.master = master
self.conn = sqlite3.connect(':memory:')
self.c = self.conn.cursor()
self.c.execute("""CREATE TABLE Employees (
FirstName text,
Surname text,
Age Integer,
Postcode VARCHAR,
Wage Integer,
Email VARCHAR,
Hours Integer
)""") #Creation of Database
self.conn.commit()
self.addEmployees() # running the function, need to fix this, Only run when "add employee" button is pressed!
def ReadData(self):
self.c.execute("SELECT * FROM Employees")
return self.c.fetchall() # this reads and returns all the data.
def addEmployees(self): # This function adds all the info the users have put into the entry in new EmployeeEmail
self.c.execute("INSERT INTO Employees VALUES (:FirstName, :Surname, :Age, :Postcode, :Wage, :Email, :Hours)",
{'FirstName':"Sharjeel" , 'Surname':"Jan" , 'Age':"21" ,
'Postcode':"aa" , 'Wage':"1220000" , 'Email':"aa" , 'Hours':"230"})
self.conn.commit()
相当简单,这里是我尝试在按下按钮时实际显示数据的地方:
^{pr2}$
您必须调用
ReadData
方法:相关问题 更多 >
编程相关推荐