Registry / database / node-red-node-sqlite

node-red-node-sqlite

JSON →
library2.0.1jsnpmunverified

Node-RED node for local SQLite database read/write operations. Current stable version is 2.0.1, released as part of the node-red-nodes collection. The package wraps the better-sqlite3 library (v2+) or sqlite3 (v1) to provide SQL query execution with support for prepared statements, parameterized queries, batch execution, SQLite extensions, and configurable reconnect timeouts. Install via npm in the Node-RED user directory with --unsafe-perm flag. Version 2.x introduces a breaking change requiring native binary rebuild on some platforms. Allows SQL injection when using raw queries via msg.topic, but prepared statements mitigate this.

npm install node-red-node-sqlite
INSTALL
IMPORT
SIG · NODE-RED-NODE-SQLI
N
node-red-node-sqlite
databasejavascriptv2.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (node)
nodes are loaded automatically by Node-RED after npm install; no manual import required
attempting require('node-red-node-sqlite') manually outside Node-RED
Node-RED nodes are loaded via the runtime, not directly imported in user scripts.
SQLite Node (configuration)
configure via Node-RED editor under 'storage' category
importing SQLite directly as a module from user code
The node is used visually in the flow editor; no code import needed.
msg.topic / msg.payload
set msg.topic to SQL query string, msg.payload for parameters
using msg.payload as the query string without msg.topic
Query mode: 'Via msg.topic' expects query in msg.topic and optional parameters in msg.payload array.

Shows basic SQLite node usage: install, configure, inject query via msg.topic with parameters, and retrieve results.

// Assuming Node-RED flow environment. // 1. Install: npm i --unsafe-perm node-red-node-sqlite // 2. Restart Node-RED. // 3. Add an inject node and a sqlite node to the canvas. // 4. Configure sqlite node: enter database path (e.g., /data/test.db). // 5. Set SQL Query: "Via msg.topic" // 6. Set SQL Statement: SELECT * FROM users WHERE name = $name // 7. In inject node, set: // msg.topic = "SELECT * FROM users WHERE name = $name" // msg.payload = ["John"] // msg.params = { $name: "John" } // if using prepared statement // 8. Deploy and inject. Output returns rows in msg.payload. // For batch: msg.topic = "INSERT INTO logs VALUES('test'); INSERT INTO logs VALUES('test2');" // Return in msg.payload: array of row objects or success/error status.
Debug
Known issues
breakingVersion 2.x updates underlying library from sqlite3 to better-sqlite3; may require native rebuild.
fix
Run `cd ~/.node-red/node_modules/sqlite3 && npm run rebuild` or similar depending on install location.
affects: >=2.0.0
gotchaSQL injection vulnerability when using 'Via msg.topic' with raw queries; user is responsible for sanitizing.
fix
Use 'Prepared Statement' mode with msg.params and parameterized queries.
affects: >=0.1.0
gotchaPrepared statement parameter object keys must include $ prefix (e.g., $name). Missing $ leads to SQLITE_RANGE error.
fix
Ensure msg.params keys start with $, e.g., { $id: 1, $name: 'John' }
affects: >=0.1.0
deprecatedVersion 1.x requires Node.js >=12; not compatible with newer Node versions due to native binding changes.
fix
Upgrade to v2.x and rebuild native dependencies.
affects: <2.0.0
gotchaNative compile can take 15-20 minutes on low-end devices like Raspberry Pi.
fix
Set `--unsafe-perm` flag during install; be patient.
affects: >=0.1.0
Errors
Common errors & fixes
GLIBC_2.38 not found
Precompiled binary incompatible with system libc version.
fix
Rebuild sqlite3 binary: `cd ~/.node-red/node_modules/sqlite3 && npm run rebuild`
SQLITE_RANGE: bind or column index out of range
Prepared statement parameter object keys missing $ prefix or mismatch with query parameters.
fix
Ensure msg.params keys match query parameters with $ prefix, e.g., { $id: 1 }
Error: The module '.../better_sqlite3.node' was compiled against a different Node.js version
Node.js version mismatch after upgrade, requiring native module rebuild.
fix
Run `npm rebuild` in Node-RED user directory or specific module folder.
Cannot find module 'better-sqlite3'
Missing native dependency after install.
fix
Reinstall with `npm install --unsafe-perm node-red-node-sqlite` ensuring build tools available.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
node-redrequiredPeer dependency - requires Node-RED runtime to load nodes; not installed automatically
better-sqlite3requiredUnderlying SQLite library for v2.x; provides native bindings and requires compile step
Agent activity
6 hits · last 30 days
node
6
Resources
node-red-node-sqlite — npm install node-red-node-sqlite · libregistry