GT Kim
GT Kim

Reputation: 339

Is there a way to share In-memory db between processes?

My c++ client on linux uses sqlite3, and I am planning to open the same db with node.js.
That is, I mean I want to use the same database file between other processes, not threads.

On my windows, I ran sqlite3.exe on two cmd shells.

In 1st cmd shell,

sqlite3.exe
sqlite> ATTACH DATABASE 'file:memdb1?mode=memory&cache=shared' AS aux1;
sqlite> create table items ( name varchar(20) );
sqlite> insert into items (name) values ('item1');

In 2nd cmd shell,

sqlite3.exe
sqlite> ATTACH DATABASE 'file:memdb1?mode=memory&cache=shared' AS aux1;
sqlite> select * from items;
Error: no such table: items

Any suggestion or comment would be thankful.

Upvotes: 2

Views: 1633

Answers (1)

CL.
CL.

Reputation: 180080

The documentation says that

all database connections sharing the in-memory database need to be in the same process.

You need to use a file, or write your own shared-memory VFS and recompile both your program and node.js to use it.

Upvotes: 0

Related Questions