Is there a way to update SQLITE database using deltas?
Asked Answered
L

4

9

I would like to know if SQLite proposes a update mechanism based on some delta file, to be clear for example an Oracle database can be synchronized with sql redo logs or snapshot logs.

Does SQLite proposes an optimized mechanism to update itself.

My use case is the following, I have a local database which must be synchronized with some remote data, in ideal world I would like to build in an optimized format the changes and only them, not all the database, is there some native SQLite mechanism or must I implement a custom one ?

Thank you

Log answered 1/8, 2012 at 7:36 Comment(0)
C
4

We have this exact same requirement and we have met this by writing insert/update/delete statements which when executed against a SQLLite database updates it.

We have a central SQLLite database which is updated from some source. The updates then are required to be propagated to other SQLLite databases. What we do is we generate SQL Scripts and execute them against the databases which needs to be updated.

Something similar will help achieve what you are looking for

Copro answered 14/8, 2012 at 11:41 Comment(0)
Q
1

The subject is now covered in another SO questions: How can I diff 2 SQLite files?

In short, there's now a built-in tool to diff two sqlite databases.

Quadrennial answered 10/6, 2016 at 18:33 Comment(0)
L
1

Some of the other answers are out of date as of 2016. The "sessions" extension was added to SQLite3 in version 3.13.0 (in 2016) which provides something similar to diff and patch. I'm in no way an expert on this, I had the same question as the OP here, and eventually found this.

https://sqlite.org/sessionintro.html

Lavalley answered 23/6, 2021 at 7:0 Comment(0)
A
0

You need a custom solution. there is nothing built-in to SQLite to do this automatically.

Note that you can write a query that spans multiple databases. Using this you can update one database from data in another entirely within SQLite. You still need to put the logic in yourself though.

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

Atlantes answered 7/8, 2012 at 20:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.