I am trying to label my button dynamically based on the database results. So in this case the button would be labeled '23'
Database
| id | number |
| 1 | 23
from tkinter import *
import pymysql as mdb
from tkinter import ttk
#functions
def functionHolder():
print("do nothing function holder")
root = Tk()
dbi = mdb.connect("localhost",port=3306, user="access", passwd="***", db="index_db" )
cursor = dbi.cursor()
cursor.execute("""SELECT number FROM caution_elements WHERE id = 1 """)
dbi.commit()
data = cursor.fetchone()[0]
dbi.close()
result =str("%s " % data)
varButt = Button(root,textvariable=data, command=functionHolder)
varButt.pack()
root.mainloop()
Button should be labeled [23] I currently get a blank button and no errors