TryGhost / node-sqlite3

SQLite3 bindings for Node.js
BSD 3-Clause "New" or "Revised" License
6.19k stars 813 forks source link

Cannot build with a custom source files for SQLite (e.g. SQLite SEE extension) #1643

Open harel opened 1 year ago

harel commented 1 year ago

Issue Summary

I'm trying to install sqlite3 on node 16.x, using a custom amalgamation file from the SEE encryption extension of sqlite3.

I have tried both with npm and yarn, with the same result - I do not believe the source file is used and instead it's compiling the original source, which then causes an exception in the node console when I try to query an encrypted database.

npm: npm install sqlite3 --build-from-source --sqlite=/path/to/see/sqlite3/source/

or yarn: npm_config_build_from_source=true npm_config_sqlite=/path/to/see/sqlite3/source yarn add sqlite3

I have also installed the sqlite dev headers (via apt).

How can I install this using a custom source file?

Thank you!

Relevant logs or output

The installation appears to go on successfully however testing out the encryption suggests it has not actually used my custom source files:

`Welcome to Node.js v16.17.1. Type ".help" for more information.

const sqlite3 = require('sqlite3').verbose(); const db = new sqlite3.Database('./encrypted.db'); const st = db.prepare("PRAGMA key='secretkey'"); st.run() Statement {} const st2 = db.prepare("select * from keys");

Uncaught [Error: SQLITE_NOTADB: file is not a database] { errno: 26, code: 'SQLITE_NOTADB' } node[982420]: ../src/node_util.cc:242:static void node::util::WeakReference::DecRef(const v8::FunctionCallbackInfo&): Assertion (weak_ref->reference_count_) >= (1)' failed. 1: 0xb02960 node::Abort() [node] 2: 0xb029de [node] 3: 0xbadb0a [node] 4: 0xd3976e [node] 5: 0xd3ab8f v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node] 6: 0x15d55d9 [node] Aborted (core dumped)

Version

5.1.2

Node.js Version

16.17.1

How did you install the library?

tried both npm and yarn. Ubuntu linux 22.04.

linonetwo commented 1 year ago

Why not use https://github.com/TryGhost/node-sqlite3/wiki/API#loadextensionpath--callback