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

feat: support connection flags

Open abalabahaha opened this issue 4 years ago • 1 comments

Rough patch that adds a constructor option for passing flags to sqlite3_open_v2. This would enable several situations listed in #483, like using a URI, without needing a custom build.

const Database = require('better-sqlite3');
const db = new Database('file:foobar.db', { flags: Database.Constants.OPEN_URI });

Relevant SQLITE_OPEN_* constants are exposed through Database.Constants (in case non-opening constants want to be exposed later).

API feels weird, would like some feedback on that.

EDIT: forgot SQLITE_OMIT_SHARED_CACHE removes shared cache support, removing that reference...

abalabahaha avatar Dec 09 '21 17:12 abalabahaha

I would rather just provide a named option, since it provides a simpler interface for users of the library. For example, you can already do { readonly: true }.

JoshuaWise avatar Dec 29 '21 23:12 JoshuaWise