def refresh_data():
cursor = db.cursor()
cursor.execute("""SELECT COUNT(name) FROM employee""")
(a,)=cursor.fetchone()
b="通讯录人数:%d"%(a)
l=tk.Label(root,text=b,justify='left').place(x=0,y=0)
sql = "SELECT * FROM EMPLOYEE "
# 执行SQL语句
cursor.execute(sql)
# 获取所有记录列表
results = cursor.fetchall()
i=50
for row in results:
name = row[0]
sex = row[1]
telephoto = row[2]
# 打印结果
a="%s %s %s"%(name,sex,telephoto)
l=tk.Message(root,text=a,width=250,justify='left').place(y=i)
i=i+20
schedule.every(1).seconds.do(refresh_data)
while True:
schedule.run_pending()
time.sleep(1)
root.mainloop()