Reputation: 1781
Code
I have this function:
#Refresh MySQL data to Treeview
def refresh(self):
self.table.delete(*self.table.get_children())
cursor = mydb.cursor()
cursor.execute("select * from requested order by done")
for row in cursor:
self.table.insert('','end', values = (row[8], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[9], row[10], row[12]))
If I insert a record or update one - using workbench. When I press refresh in Tkinter, it does not show any new or amended data. Just stays as it is.
But - If I quit Tkinter app - re-open it - click refresh
it will show new amended data.
If the tkinter app is running - If I try to run the following query: truncate table
using workbench - MySQL will not complete the query the action until I close the tkinter app
What it should do
When I activate the function refresh
- it should remove all the current data in treeview and update it with existing values within MySQL.
Quesiton
How can I achieve this?
Upvotes: 0
Views: 1093
Reputation: 1781
From @brunodesthuilliers link in comments MySQL transaction isolation level has helped me find what was wrong!
By running this query in MySQL Workbench:
SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
Has allowed me to update records from MySQL and run this function below - without a problem!
#Refresh MySQL data to Treeview
def refresh(self):
self.table.delete(*self.table.get_children())
cursor = mydb.cursor()
cursor.execute("select * from requested order by done")
for row in cursor:
self.table.insert('','end', values = (row[8], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[9], row[10], row[12]))
Upvotes: 1