4

It's possible to create an in memory SQlite database:

rc = sqlite3_open(":memory:", &db);

but if I've understood the documentation correctly, this database is local to the app that created it.

I have a requirement for an in memory SQLite database which can be accessed by several apps. Other than creating the database on a ramdisk, is there any way of doing this?

This is for an embedded linux platform.

3 Answers 3

5

You can't share an in-memory database across processes – it's really not designed to do that because it lacks the right sort of integrity promises (but which does mean it's faster) – so either put the database on more permanent storage (such as the ramdisk) or put the DB in a single process (the “database manager”) and use some form of local communication strategy (unix-domain sockets, named pipes, etc.) to allow the other processes to ask the database manager to do a query for them.

Sign up to request clarification or add additional context in comments.

Comments

1

No, you will have to create the db on a ramdisk/tmpfs, if you want it to be in memory and share it with other applications.

Comments

0

You could create the database (and a cross-process lock) in the process with the necessary lifetime in shared memory. All you have to do then, is treat it as any other shared memory resource (remembering to lock/unlock when accessing it). Unfortunately, I think this might require some meddling with SQLITE source to use the memory you provide (shared) rather than allocate its own.

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/shm.h.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.