zedocs
GitHub ↗
Build with Ze

SQLite

Connect to SQLite, execute parameterized SQL, and query rows in Ze.

Database functions are available in the Ze CLI, REPL, and web handlers through the standard library. SQLite runs locally without a separate database server. Ze now depends on the Go SQLite driver modernc.org/sqlite.

EnglishBisayaResult
db_open(path)abli_tipiganan(path)SQLite connection; use ":memory:" for a temporary database
db_exec(db, sql, ...)usba_tipiganan(db, sql, ...)Number of affected rows
db_query(db, sql, ...)pangutana_tipiganan(db, sql, ...)List of records keyed by column names; an empty query returns []
db_close(db)sirad_tipiganan(db)Close the connection

Read columns with rows[0]["ulo"]. Missing columns return wala. SQL NULL becomes wala, integers and real values become Ze numbers, and text becomes Ze strings. Ze numbers use float64, so integers beyond 2^53−1 may lose precision; BLOB values are converted to strings. Close connections explicitly, preferably in a finally / kataposang block. SQL or connection errors become catchable Ze runtime errors.

Pass values using ? placeholders rather than concatenating them into SQL. These functions execute trusted SQL supplied by the program. SQL keywords keep their standard spelling even in a Bisaya Ze program.

ibutang tipigan = abli_tipiganan("buluhaton.db")
sulayi:
    usba_tipiganan(tipigan, "CREATE TABLE IF NOT EXISTS buluhaton (id INTEGER PRIMARY KEY, ulo TEXT NOT NULL)")
    usba_tipiganan(tipigan, "INSERT INTO buluhaton (ulo) VALUES (?)", "Pagtuon sa Ze")
    ibutang mga_laray = pangutana_tipiganan(tipigan, "SELECT id, ulo FROM buluhaton")
    para laray sa mga_laray:
        ipakita laray["id"], laray["ulo"]
    usba_tipiganan(tipigan, "UPDATE buluhaton SET ulo = ? WHERE id = ?", "Pagpraktis", 1)
    usba_tipiganan(tipigan, "DELETE FROM buluhaton WHERE id = ?", 1)
kataposang:
    sirad_tipiganan(tipigan)

Each connection uses one underlying SQLite connection, enables foreign keys, and waits up to five seconds for database locks. There are no transaction helpers or migrations yet; db_exec can execute schema SQL. Local file paths are relative to the process working directory.

Help make these docs better.Edit this page on GitHub ↗

Find a guide or search the language reference.