Wednesday, April 28, 2010

Re: Transaction commit with cursor.execute

On Thu, Apr 29, 2010 at 12:59 AM, idle sign <idlesign@gmail.com> wrote:
> I think I spotted something weird. May be someone could explain that?
>
> 1. In Django 1.2 define two DBs (let it be sqlite), one of which name
> 'test'.
> 2. Define DB router for 'testapp' so that it always uses 'test' DB.
> 3. Use 'commit_manually' decorator for 'test' view.
> 4. In 'test' view define 'cursor' pointing to 'test' DB.
> 5. Execute some INSERTs and commit
> *. 'Samples' object (exported from model) would show all inserted
> object, but nothing would be written into DB.

The problem is on this line:

>    transaction.commit()

By default (for backwards compatibility), commit() operates on the
default database. If you want to commit results on the 'test'
connection, you need to provide a 'using' argument:

transaction.commit(using='test')

Yours,
Russ Magee %-)

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate