On 11 Feb 2011, at 2:37am, Yuzem wrote:

> Simon Slavin-3 wrote:
>> 
> 
>> By looking at the file on disk ?  Are you taking into account the journal
>> file ? 
>> 
> 
> Yes, I do all the counts

So if I deleted one record and created another you wouldn't spot it ?

> and save the data to a file and then if the file is
> newer then the database I use the file else I count again.

Your process is trustworthy only when you are certain that the database file is 
not currently open.  If there's a chance that some application may be modifying 
the file when you check these things then the results you get may not be 
up-to-date.

The only way to correctly tell if the data in the database has changed is to 
use SQLite calls.  Also, your operating system does not update the file 
attributes every time the contents of the file changes.  It will often wait for 
a change of sector or a buffer to be flushed.

> No, I am not taking the journal file into account, I don't know what you
> mean by that.

SQLite uses a journal file to temporarily store change to the database.  You 
will find this journal file appearing in the same directory as the database 
file if you have the database open and have made changes.  These changes will 
eventually be saved in the database file -- definitely when you close all the 
SQLite handles to that file -- but until then you have no way of knowing what 
data SQLite considers is actually in the database apart from using SQLite calls.

Read here, especially sections 2.1 to 2.3, about the temporary files SQLite 
makes:

http://www.sqlite.org/tempfiles.html

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to