Does django connection cursor auto commit after each .execute() query?

from django.db import connection

def executeQuery(query, params):
    cur=connection.cursor()
    cur.execute(query, params) // this is update query
    cur.close()

I have series of queries and I call this method for each query, but it looks like it rollbacks entire operation if any query (let's say 3rd query) gets failed.

I thought, after execute(), it immediately commit it and it does not depend on the next query.

Shouldn't django has auto commit feature?


Solution 1:

Database altering operations are automatically committed. However, if you are using the django.middleware.transaction.TransactionMiddleware or something similar, then they will be only committed if the page rendering finishes without any error, otherwise a rollback will happen.

For further details refer to the documentation for django 1.5 (the version used in the question). Check the latest documentation too.