I use the mysql.connector
module to fetch rows in a python script but when I update a table using the terminal, my script doesen't see any changes.
My code is this:
import mysql.connector
database = mysql.connector.connect(host='localhost', user='root', passwd='password', database='my_db')
cursor = database.cursor()
cursor.execute('SELECT * FROM my_table')
print(cursor.fetchall())
cursor.execute('SELECT * FROM my_table')
print(cursor.fetchall())
The first time it always reads the correct values but at the second time it does not see changes even when I have update my database.
I tried this solutions but it still did not work:
- I tried updating the database using the
mysql.connector
module - I tried installing some older versions
- I tried using the root user