greenServeFEgreenServeFE

Documentation home / Native Module API

Native Module API

SQLite Database API

SQLite connection lifecycle, parameterized SQL execution, row queries and error reporting.

Purpose

SQLite connection lifecycle, parameterized SQL execution, row queries and error reporting.

Exports registered by the module initializer

ExportRole
openopen exported function or value
closeclose exported function or value
execexec exported function or value
queryquery exported function or value
errorerror exported function or value

Usage example

import gs_db;
define db = gs_db.open("app.db");
gs_db.exec(db, "CREATE TABLE IF NOT EXISTS notes (id INTEGER, body TEXT)");
gs_db.exec(db, "INSERT INTO notes VALUES (?, ?)", [1, "hello"]);
print(gs_db.query(db, "SELECT * FROM notes"));
gs_db.close(db);
open(path) returns a numeric connection handle. exec/query accept optional parameter arrays bound to SQLite placeholders. BLOB values are returned as lowercase hexadecimal strings. Requires SQLite.

Related references

Module catalog · Native ABI · GSVE language