This plugin is a wrapper around sqlite3.
Follow the instructions in our manual to add our package repository and then run the below command.
apt-get install halon-extras-sqlite
yum install halon-extras-sqlite
For the configuration schema, see sqlite-app.schema.json.
plugins:
- id: sqlite
config:
default_profile: sqlite
profiles:
- id: sqlite
filename: /tmp/database.db
pool_size: 32
foreign_keys: true
readonly: false
These classes needs to be imported from the extras://sqlite module path.
The SQLite class is a sqlite3 wrapper class. On error an exception is thrown.
Pass a "prepared" statement to SQLite. On error an exception is thrown. See the table below for the data types mapping.
| SQLite | HSL |
|---|---|
SQLITE_TEXT |
string |
SQLITE_INTEGER |
string |
SQLITE_FLOAT |
number |
SQLITE_BLOB |
string |
SQLITE_NULL |
none |
import { SQLite } from "extras://sqlite";
// Create "SQLite" instance with an (optional) config profile
$sqlite = SQLite("sqlite");
$sqlite->query("CREATE TABLE IF NOT EXISTS employee (name VARCHAR(255), salary INT, working BOOLEAN, age SMALLINT)");
$sqlite->query("INSERT INTO employee (name, salary, working, age) VALUES (?, ?, ?, ?)", ["John Doe", 54321, true, 36]);
$sqlite->query("INSERT INTO employee (name, salary, working, age) VALUES (?, ?, ?, ?)", ["Jane Doe", 54321, false, 36]);
echo $sqlite->query("SELECT * FROM employee");
// [0=>["name"=>"John Doe","salary"=>"54321","working"=>"1","age"=>"36"],1=>["name"=>"Jane Doe","salary"=>"54321","working"=>"0","age"=>"36"]]