Database Query Contains Old Data

John Nagle nagle at animats.com
Fri May 23 11:18:50 EDT 2008


Paul Boddie wrote:
> On 21 Mai, 15:22, giraffe... at gmail.com wrote:
>> I did and I confirmed this by modifying the data, selecting it from
>> the mysql command line client to verify the changes, then running the
>> report again. If I exit the application and then start it again,
>> everything works as expected until the second instance of the report
>> is run.
> 
> Note that if you have a connection open in your program, especially if
> that connection has already been used to select data, it may be the
> case that you then have to perform a rollback or commit before
> attempting to access newly added data. 

     Exactly.  Although it seems counterintutive, it's not enough
to do a COMMIT after UPDATE and INSERT operations.  You also have to
do a COMMIT after a SELECT if you're going to reuse the database handle
and do another SELECT.  Otherwise, you reread the same data forever.

     COMMIT, by the way, is per database handle, so if you have
multiple database handles, each needs to handle its own COMMIT needs.

				John Nagle



More information about the Python-list mailing list