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

Can I deserialize into an existing DB?

Open VivinLancelot opened this issue 3 years ago • 1 comments

I'd like to use several in-mem DBs in the same thread. So I am considering if I can create them like: new Database('file:memdb1?mode=memory&cache=shared') as mentioned in https://www.sqlite.org/inmemorydb.html.

But after the DB created, I cannot find a way to deserialize into it what I serialized before. I see the serialize/deserialize APIs were supported in #573 but it seems I can only deserialize into the :memory: without shared cache.

So,

  • Does better-sqlite3 support named in-mem DBs with shared cache?
  • Can I deserialize into an in-mem DB with shared cache?

VivinLancelot avatar Jul 26 '22 11:07 VivinLancelot

This isn't currently supported. Even URI filenames aren't supported by default, so you wouldn't even be able to open an in-memory database with shared cache. There are no plans to support this feature, because there isn't much of a point in having shared-cache database in Node.js; since Node.js is single-threaded, you might as well just use the same database object for the entire program.

JoshuaWise avatar Aug 22 '22 01:08 JoshuaWise