Skip to main content

sqlite

Store and query data locally with SQLite - the perfect embedded database for edge devices.

Overview

The sqlite node provides local database storage using SQLite. Perfect for edge devices, it requires no server setup, stores data in a single file, and survives reboots. Ideal for logging sensor data, caching values, and storing configuration.

Zero
Configuration
ACID
Compliant
281 TB
Max DB Size
Single File
Storage

Properties

Property Type Default Description
db string "data.db" Path to database file
mode string "query" "query", "batch", or "prepared"
sql string "" SQL statement (can use msg.topic)
params string "msg.payload" Path to parameters array

Inputs

Insert
{
  "topic": "INSERT INTO readings (sensor, value) VALUES (?, ?)",
  "payload": ["temp1", 23.5]
}
Select
{
  "topic": "SELECT * FROM readings WHERE sensor = ?",
  "payload": ["temp1"]
}

Outputs

Query Result
{
  "payload": [
    {"id": 1, "sensor": "temp1", "value": 23.5},
    {"id": 2, "sensor": "temp1", "value": 24.1}
  ],
  "affectedRows": 0,
  "lastInsertId": null
}

Example: Sensor Data Logger

Log sensor readings and query historical data.

// Initialize table (run once)
CREATE TABLE IF NOT EXISTS readings (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    sensor TEXT NOT NULL,
    value REAL NOT NULL,
    timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
);

// Insert reading
INSERT INTO readings (sensor, value) VALUES (?, ?);

// Query last 24 hours
SELECT * FROM readings
WHERE timestamp > datetime('now', '-24 hours')
ORDER BY timestamp DESC;

Related Nodes