Home > OS >  How to enable autocommit in python-mysql integration using mysql.connector?
How to enable autocommit in python-mysql integration using mysql.connector?

Time:08-12

I am working on a python project using mysql database integration by mysql.connector package. I want to turn on autocommit but dont know how to do that. This is how I connected with mysql:

mydb = mysql.connector.connect(
    host="localhost",
    user="root",
    passwd="admin"
)

Please tell me how to turn on autocommit if you know so.

CodePudding user response:

Given your example, you should use this line of code:

mydb.autocommit = True

This is in the documentation. See https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlconnection-autocommit.html

  • Related