Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does SQLite support replication?

In an application which embeds SQLite3 and uses an in-memory database, is it possible to replicate the database between two running instances of the application? I could do this by hand with a homebrew protocol duplicating all my DB accesses, but it seems like something that should be done inside the DB layer.

like image 374
kdt Avatar asked Dec 11 '09 13:12

kdt


People also ask

What are the limitations of SQLite?

An SQLite database is limited in size to 281 terabytes (248 bytes, 256 tibibytes). And even if it could handle larger databases, SQLite stores the entire database in a single disk file and many filesystems limit the maximum size of files to something less than this.

Why is SQLite not good for production?

SQLite doesn't support any kind of concurrency, so you may have problems running it on a production website.

Does sqlite3 support concurrency?

Also, sqlite3 has a deceptively simple mechanism for ensuring maximum concurrency (which is also thread-safe) as described in their File locking and Concurrency document.

Does SQLite have concurrency?

Overview. Usually, SQLite allows at most one writer to proceed concurrently. The BEGIN CONCURRENT enhancement allows multiple writers to process write transactions simultanously if the database is in "wal" or "wal2" mode, although the system still serializes COMMIT commands.

How are replicas handled in SQLite?

These replicas can be handled by the same application or another one, in the same device or a distant one. Each connection can use a different communication protocol, and a different connection direction. Updates in the replicas use the internal SQLite transaction engine at the pager level.

What is SQL server replication?

SQL Server Replication. Replication is a set of technologies for copying and distributing data and database objects from one database to another and then synchronizing between databases to maintain consistency.

What happens to SQLite data when one node fails?

For example say you have a cluster of three application nodes, all sharing the same distributed dqlite database. If one node fails or is shutdown for maintenance, then the remaining two nodes can continue to access the database and operate normally. Here follow the details about what SQLite data is actually replicated and how.

Can I use copycat instead of SQLite?

You can also use CopyCat, which support SQLite as well as a few other database types. Apparently it only supports SQLite under very limited conditions (e.g. using Delphi?!)


1 Answers

Brute force approach: Send it the ".dump" command to create a text representation of the data. Read that data in into the second database. Not sure you can use that.

If you need a fine grained update (sending a copy of each upto the other copy), have a look at sqlite3_update_hook

But how do you plan to handle errors? For example, what happens when the copy of the DB in app2 can't make an update for some reason?

To solve this, move the database to a server process and have the two apps talk to it.

like image 167
Aaron Digulla Avatar answered Oct 05 '22 11:10

Aaron Digulla