Documentation
¶
Overview ¶
Package sqlite is the sqlite database plugin. Scripts import it as scriptling.sqlite and get a relational API shared with the sql plugin:
import scriptling.sqlite as sqlite
conn = sqlite.connect("app.db")
conn.execute("create table t (id integer primary key, name text)")
conn.execute("insert into t (name) values (?)", "ada")
rows = conn.query("select * from t where name = ?", "ada")
conn.close()
The database file must fall inside the host's allowed paths (":memory:" is always allowed). The same library serves two modes: an external plugin process (plugins/sqlite/cmd) and compiled-in registration (build tag plugin_sqlite) — Build is the single registration for both.
Index ¶
Constants ¶
const ConnectSource = `def connect(path=":memory:", timeout_ms=5000):
return Connection(path, timeout_ms=timeout_ms)
`
ConnectSource is the scriptling-source wrapper for connect() used in external plugin mode, where a Go function cannot return an instance over the wire: it constructs the Connection class through the plugin object protocol instead. In compiled-in mode the Go builtin below is used.
const Description = "SQLite embedded database (pure Go)"
Description is the plugin metadata description.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build(policy plugin.PolicySource) *object.Library
Build returns the scriptling.sqlite library. policy is read at call time so an external plugin sees the policy its handshake delivered (the handshake always precedes the first function call).
func RegisterInProcess ¶
func RegisterInProcess(registrar interface {
RegisterLibrary(*object.Library)
RegisterScriptLibrary(name string, script string) error
}, policy *plugin.Policy)
RegisterInProcess registers both halves for embedders and tests: the native twin library and the scriptling.sqlite script module.
func ScriptModule ¶
func ScriptModule() string
ScriptModule is the user-facing scriptling.sqlite module for compiled-in registration: the Connection wrapper (with get_orm) plus the shared ORM kit, importing the native twin.
Types ¶
This section is empty.