muthu kumar
muthu kumar

Reputation: 15

Regarding SQLite replication

I am working with SQLite in C++ on Linux. I want to replicate the SQLite database in another machine. I want to read the SQLite database file using fstream and create a copy in the other machine.

My code :

 ifstream _fstream;
_fstream.open("Sourcefile",ios::in); 
 ofstream _ostream;
_ostream.open("ReplicatedFile",ios::out);
_ostream << _fstream;
_ostream.close();
_fstream.close();

Upvotes: 1

Views: 2664

Answers (2)

mOna
mOna

Reputation: 2459

I am not sure if this is what you want, but if you need to do the replication across multiple servers (distributed), Rqlite might be suited for you.

rqlite is a distributed relational database, which uses SQLite as its storage engine. rqlite uses Raft to achieve consensus across all the instances of the SQLite databases, ensuring that every change made to the system is made to a quorum of SQLite databases, or none at all.

You can read more here: http://www.philipotoole.com/replicating-sqlite-using-raft-consensus/

Upvotes: 0

Andrew
Andrew

Reputation: 2630

You might want to look at the built in SQLite Backup API which allows for online backup of the database. This could be used to create a form of replication, you would of course have to move the file to a remote location yourself (if desired). It is probably best to use the sqlite_backup_*() functions rather than directly accessing the file(s), since the sqlite functions will lock the database.

Upvotes: 1

Related Questions