Search code examples
node.jssqlitepersistin-memory

Nodejs persist a sqlite in-memory database


I'm using the nodejs sqlite library (https://github.com/mapbox/node-sqlite3). How can i persist an in-memory database to disk? Since in the c/c++ implementation there are the backup api how can i persist in nodejs with this library? (or with another library/mechanism)


Solution

  • In 2016, using the backup API was the only way. And Node.js did not implement this API. But now, see Jared's answer.

    Anyway, just use a normal, on-disk database. You can make it as unsafe as an in-memory database with PRAGMA synchronous = OFF.