Reputation: 21
I have created a python program (with python3 and mysql.connector library) that updates the value of a column in a MySQL DB. When I run the command SELECT * FROM table_name
in python seems to have changed the value, but when I run this command in MySql WorkBench it drops me the table with no changes applied.
Here is my code:
db = mysql.connector.connect(
host = "IP adress",
user = "user",
passwd = "password"
)
mycursor = db.cursor()
mycursor.execute("USE db_name;")
mycursor.execute('UPDATE table_name SET column = value WHERE condition;')
mycursor.execute('SELECT * FROM table_name;')
print(mycursor.fetchone())
As I have previously mentioned, when I run the command SELECT * FROM table_name
in python it seems like the changes have been applied, but when I run it in MySql Workbench it seems like no changes have been applied. Does anybody know what the problem is?
Upvotes: 2
Views: 57