Cursor Delete Not Committing

1 view
Skip to first unread message

Steve Wedig

unread,
Nov 16, 2006, 8:25:53 AM11/16/06
to django...@googlegroups.com
I feel like this is a simple question, yet I haven't been able to
solve it at 5am :)

I'm trying to delete through a cursor like this:

from django.db import models, connection, transaction

cursor = connection.cursor()
cursor.execute( query )

But it appears to not be committing. I suspect this because the change
doesn't register, and when I try to do the same delete from the
postgres command line, it doesn't complete until I close python (so i
figure it is releasing a lock or something).

Ok, just solved it actually...
I looked in the db wrapping and tried calling connection._commit().
Since its a private attribute, I assume I'm doing something wrong
though. Is that the case?

Thanks,
Steve

Russell Keith-Magee

unread,
Nov 17, 2006, 8:07:24 PM11/17/06
to django...@googlegroups.com
On 11/16/06, Steve Wedig <steve...@gmail.com> wrote:
>
> Ok, just solved it actually...
> I looked in the db wrapping and tried calling connection._commit().
> Since its a private attribute, I assume I'm doing something wrong
> though. Is that the case?

Looks like you might be getting caught up on transactions.

transaction.commit()

will commit all the executed statements to the database. It is
effectively just a call to connection._commit(), plus some other
transaction-related housekeeping.

Yours,
Russ Magee %-)

Steve Wedig

unread,
Nov 21, 2006, 8:15:18 AM11/21/06
to django...@googlegroups.com
Thanks for the idea Russ. When I try that, I get a
TransactionManagementError (This code isn't under transaction
management), which makes sense, since I'm not trying to do a
transaction.

is it possible that custom inserts in postgres require an explicit
call to commit, even when not under transaction? If thats the case,
then perhaps connection._commit() shouldn't private. If not, then I'm
still uncertain :)

Best,
Steve

Reply all
Reply to author
Forward
0 new messages