I just switched to Django 1.6 (with Posgres 9.1) and there is a few questions that I couldn't answer myself:
(Answered) Is there a statement that prints/shows me if I am currently inside one or more and in which transaction.atomic
blocks?
(Answered) I neither have TransactionMiddleware
enabled nor set ATOMIC_REQUESTS
to True. So per default my code is not wrapped inside a transaction.atomic
block, correct?
Are sql statements that are executed via cursor committed properly when executed inside a transaction.atomic
block? Is there another/better way to commit them?
with transaction.atomic():
cursor = connection.cursor()
cursor.execute(sql)
Do I need to wrap cursor.executemany()
in a transaction.atomic
block or does the execution already happen atomically?
How can I see the current autocommit
status? When is the status set, at the beginning of a connection, a transaction, as global database setting?
To answer one of your questions:
You can find out if you are currently in an atomic block using the connection
object returned from:
from django.db.transaction import get_connection
or any of the connection objects inside of django.db.connections
which has an in_atomic_block
property.
I feel like its going to be easiest just to look through the django source
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