On 7 Mar 2016, at 12:24pm, Sairam Gaddam <gaddamsairam at gmail.com> wrote:
> I want to make note of those changes and replicate in another DB. Okay. Reading changes from the WAL file is perhaps a poor way to do this. First, not all SQLite databases have a WAL file. Second, SQLite can put changes in the WAL file and then immediately process them and overwrite the contents of the file. Third, because you are modifying database files outside of sqlite you stand the chance of corrupting those files. Fourth, you would need to have a constantly-running process to see what is going on and this wastes a lot of CPU and power. The standards way to ensure database replication is to do the following. Either A) Always make changes via your own library routine which logs them OR B) Rewrite sqlite3_exec() or sqlite3_prepare() to log changes as well as do their normal job. To log a change, create a new SQL table called 'change_log' and add to it all commands which start with INSERT, UPDATE or DROP. Then your routine simply reads that table, executes those commands on another database file (you can use ATTACH or send the changes as a text file to another computer) then does "DELETE FROM change_log". If your database files are small and you do not make changes frequently then you could instead use the SQLite Backup API: <https://www.sqlite.org/backup.html> Simon.

