'Python program can't update mysql db column

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?



Solution 1:[1]

try : before print(mycursor.fetchone())

db.commit()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 debugger