Sairam,

Just in case it's useful and you've not see it, Simon Slavin pointed out
this "rqlite" project for replicated sqlite in an email from 25 Feb.



Donald
================================================
Simon Slavin slavins at bigfraud.org via
<https://support.google.com/mail/answer/1311182?hl=en>
mailinglists.sqlite.org
Feb 25 (11 days ago)
to SQLite
This looks interesting.

<http://www.philipotoole.com/replicating-sqlite-using-raft-consensus/>

<https://github.com/otoolep/rqlite>

It allows you to set up multiple computers on the internet to keep copies
of a database in synch.  Changes in one are promulgated to them all.  As a
side effect it proves a TCP server for SQL commands.

Haven't had time to evaluate it, but there are people here who can do that
far better than I can.

Simon.

On Mon, Mar 7, 2016 at 7:36 AM, Simon Slavin <slavins at bigfraud.org> wrote:

>
> 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.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>

Reply via email to