-
-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option for enabling URI format #483
Comments
I think #475 is related. I personally think the first parameter to the |
Yes, agreed. If the database starts with |
The string passed to the |
One might add that the absence of |
…er-sqlite3#483 which prevents two connections to the same RAM DB
@JoshuaWise Any real reason for setting SQLITE_USE_URI=0? I too would like to use the prebuilt binary but need to pass QP in order to use in-memory DB from multiple connections. |
I think I could write a more detailed view of the current situation, but to keep it short for now it is because of the SQLITE_OMIT_SHARED_CACHE setting that you can not open several connections to the same in-memory DB. It naturally does work with file-based DBs. My use case for this is RDBMS-backed procedural programming which SQLite is great for. It becomes much faster with RAM DBs as opposed to file-based ones, and you can still eventually persist data (save the DB as an Tangentially I think this is also related to why you cannot issue DB queries from inside User-Defined Functions. You can, in unsafe mode, issue a second query directly, but try the same from a UDF and it won't work, not even within the same query. One workaround for that is opening a second connection but of course with SQLITE_OMIT_SHARED_CACHE and SQLITE_USE_URI=0 this is not going to work with in-memory DBs. |
I compiled it with
import SQLite from "better-sqlit3";
const dbh1 = new SQLite( "file::memory:?cache=shared" );
const dbh2 = new SQLite( "file::memory:?cache=shared" );
dbh1.exec( `
CREATE TABLE "a" (
"id" integer PRIMARY KEY
);
INSERT INTO "a" DEFAULT VALUES;
` );
const q = `SELECT "id" FROM "a"`;
console.log( dbh1.prepare( q ).all() ); // [ { id: 1 } ]
console.log( dbh2.prepare( q ).all() ); // SqliteError: no such table: a Does anybody know what is the problem? |
@JoshuaWise Why not enable |
TIL you can change this at runtime
@JoshuaWise you might not be aware, but |
…E_USE_URI=1` I'm trying to use `better-sqlite3` with an SQLite that is compiled with `SQLITE_USE_URI=1`: ```js const db = SQLite(`file:///foo/bar?vfs=myfs&mode=ro&immutable=1`); ``` This, however, doesn't work right now, since there's an erroneous assertion in the database creation. With this patch, I can successfully connect to database. References WiseLibs#483
…E_USE_URI=1` I'm trying to use `better-sqlite3` with an SQLite that is compiled with `SQLITE_USE_URI=1`: ```js const db = SQLite(`file:///foo/bar?vfs=myfs&mode=ro&immutable=1`); ``` This, however, doesn't work right now, since there's an erroneous assertion in the database creation. With this patch, I can successfully connect to database. References WiseLibs#483
Enable URI format
Enable e.g.
file:mydb.db?cache=shared
URIs when opening Database by passing a new option to enable URI format forsqlite_open_v2()
.Pls. see: https://www.sqlite.org/uri.html
The text was updated successfully, but these errors were encountered: