node-sqlite3 icon indicating copy to clipboard operation
node-sqlite3 copied to clipboard

Ability to dump and load the data of a database

Open terrakuh opened this issue 2 years ago • 2 comments

Summary

Are there any plans to provide functionality to dump/load the SQLite database to/from raw memory buffers? I've seen #709 but I think that issue is obsolete.

This would enable the user to work solely on in-memory database and make backups.

Proposed implementation

I have implemented the experimental methods db.dump() and db.load() which map to the SQLite equivalent sqlite3_serialize() and sqlite3_deserialize() at my fork. It is not 100% complete and does not contain tests.

terrakuh avatar Feb 14 '23 17:02 terrakuh

For anyone who's interested: You can apply the dump_and_load.patch.txt patch:

git am < dump_and_load.patch.txt

Basic usage:

db1.dump("main", (err, data) => {
  db2.load("main", data, (err) => {})
})

terrakuh avatar Feb 22 '23 09:02 terrakuh

Uploading Unknown.zip…

Deadman878787 avatar Mar 27 '23 19:03 Deadman878787