TryGhost / node-sqlite3

SQLite3 bindings for Node.js
BSD 3-Clause "New" or "Revised" License
6.23k stars 816 forks source link

Ability to dump and load the data of a database #1681

Open terrakuh opened 1 year ago

terrakuh commented 1 year ago

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 commented 1 year ago

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) => {})
})
Deadman878787 commented 1 year ago

[Uploading Unknown.zip…]()