On May 5, 2010, at 11:51 PM, Kenny Daily wrote:

> I had a similar problem too. I was using the cursor obtained from:
> 
> cursor = myannotdb.sliceDB.cursor
> 
> I would not see insert statements that I executed using this cursor. I
> fixed (with other issues coming from doing this) by calling:
> 
> cursor.execute("BEGIN TRANSACTION")
> 
> before each sql insert call. But, if the script running this fails, it
> leave the database in a locked state.

To avoid leaving the database in a locked state, seems like you could use 
try-finally to ensure that the correct operation for closing the transaction is 
carried out no matter happens during the script, e.g. something like

cursor.execute("BEGIN TRANSACTION")
try:
   # whatever insert operations you want to perform...
finally:
   cursor.execute("ROLLBACK TRANSACTION") # or whatever is appropriate to 
release the lock...

-- Chris

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

Reply via email to