SQLite3, data not found

John Nagle nagle at animats.com
Sat Mar 17 13:51:04 EDT 2007


jim-on-linux wrote:
> On Friday 16 March 2007 18:23, Jerry Hill wrote:
> 
>>On 3/16/07, jim-on-linux <inq1ltd at verizon.net> 
> 
> wrote:
> 
>>>Below, the first select produces results but,
>>>after closing then re-opening the database
>>>the select produces an empty list.  Anyone
>>>know the reason ??
>>
>>When you first open a connection, you
>>implicitly begin a transaction. You need to
>>call con.commit() before you close the
>>connection, or your transaction will be rolled
>>back when you close() it.  If don't want to
>>bother with transaction handling, you can turn
>>it off when you open the connection, like this:
>>con = sqlite3.connect('myData',
>>isolation_level=None)
>>
>>See the Python Database API 2.0 PEP for more
>>details about the behavior required of DB-API
>>2.0 compliant interfaces:
>>http://www.python.org/dev/peps/pep-0249/
>>
>>--
>>Jerry
> 
> 
> Thanks, this saves a lot of con.commit action.
> And the website is valuable.
> 
> jim-on-linux 

    Don't turn off atomic transactions, use them.
Otherwise, two copies of your program running at the
same time will probably not do what you want.
Just call "commit" at the end of each transaction.

			John Nagle



More information about the Python-list mailing list