Let me give you some context first.
I am making a project using tkinter, python and MySQL. In my project, every time the user clicks on create button in the tkinter window(which i will be calling root henceforth), button is created and displayed in the root window.
#Creating the button for that specific date
btn = tk.Button(root, text=dateoftable) #dateoftable contains some string value
btn.number=btnnumber #btnnumber is a unique number for each button that increments by one everytime a new button is created
btn.place(x=x, y=y, width=100, height=100) #x and y are predefined variables
#Adding the button object to the dictionary
tables[btnnumber]=btn #tables is a dictionary
So all the created button objects are stored in the tables dictionary.
Now, every time a button is added onto the root window, the tkinter button object is inserted int the MySQl table which has btnobject(Primary Key) anddateoftable as the names of the columns of the table timetablebtn. Just assume dateoftable to contain non-unique arbitrary string values.
lastelem = list(tables.values())[-1] #gets the most recently added button object on the root window
#**The problem is in the below statement**
config.cursorobj.execute("INSERT INTO timetablebtn VALUES ('{0}','{1}')".format(str(lastelem), dateoftable))
config.mysqlobj.commit()
As you can see, I am storing the button object as a string in the MySQL table, which is a problem because, I cannot reference it again when I call it from the database, it just becomes a dummy string value.
So i want to know if there is a way to store objects onto MySQL. If that's not possible, I want to know if there is a way to reference the same button object when I retrieve the value from my table in the database.
If any more information is required, I will edit the question and code and post it.
Thanks in advance.