I have an app that uses a few custom SQL calls through
connection.cursor()
as described in 
http://docs.djangoproject.com/en/dev/topics/db/sql/#topics-db-sql.
However they don't display the same transaction semantics as
specified
in 
http://docs.djangoproject.com/en/dev/topics/db/transactions/#topics-db-transactions.

For example, if I have a view that inserts some data using
connection.cursor(),
then throws an exception, the data inserted remains in the database.

I'm not sure if the behaviour I'm observing is a bug, or if I've just
failed to associate
the cursor with the transaction in some way.  If it's something I've
missed, could someone
advise me on how to do that?

For example (views.py):

from django.http import HttpResponse

def test1(request):
  from django.db import connection
  cur = connection.cursor()
        # this data is inserted even though the view does not succeed
  cur.execute("insert into table (column) values ('value');")
  raise "This view should not change the database"
  return HttpResponse("hello")

This happens whether or not I explicitly mark the view with
@transaction.commit_on_success.

I'm using postgresql_psycopg2.

Thanks.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to