SQLite Forum

In memory db actually creating file
Login

In memory db actually creating file

(1) By rlake (rob.lake) on 2021-09-14 19:16:39 [link] [source]

I'm using sqlite3, built from source, to create an in memory database but sqlite3 is creating a file in the working directory. Here's a simple program that I used to show the issue.

#include <sqlite3.h>

int main(int argc, char** argv)
{
    sqlite3* db;
    sqlite3_open("file:memdb1?mode=memory&cache=shared", &db);
    const char* sql = "CREATE TABLE IF NOT EXISTS TEST (ID INT);"
                      "INSERT INTO TEST VALUES (1), (2);";

    sqlite3_exec(db, sql, 0, 0, 0);
    sqlite3_close(db);
    return 0;
}

When I use the sqlite3 lib packaged with Ubuntu 20.04 a file is not created. Has anybody had this issue when using sqlite built from source?

(2) By Richard Hipp (drh) on 2021-09-14 19:21:03 in reply to 1 [source]

Maybe you need to enable URI filenames. They are disabled by default for compatibility with older versions of SQLite.

(3) By rlake (rob.lake) on 2021-09-15 13:04:30 in reply to 2 [link] [source]

Thanks, that's exactly what I'm looking for.