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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With