Capy-Bearer Documentation

sqlite_info

host call

Capy

function sqlite_info(handle : u64, key : string) any

Description

sqlite_info() reads the latest error text, the last inserted row ID, or the changed-row count.

The error value is connected after a successful open and ok after a successful query. It is not empty on success. Read it immediately after the operation because a later query replaces it.

A result without rows can mean a successful write, a SELECT without matches, or a failed statement. Use the status to distinguish these cases.

The insert_id result uses signed s64, including valid negative row IDs. The affected_rows result uses u64 without 32-bit truncation. The error result is a string. Use a converter only when an operation needs a static type.

Parameters

handle : the SQLite connection handle

key : error, insert_id, or affected_rows

Return Values

The value for key.

Errors

The function stops with an error for an unknown key. The error lists the valid keys.

Example

Capy

var db := sqlite_connect(":memory:").value ?? u64(0)
sqlite_query(db, "create table t(id integer primary key)")
sqlite_query(db, "insert into t values(1)")
var message := sqlite_info(db, "error")
var id := sqlite_info(db, "insert_id")
var rows := sqlite_info(db, "affected_rows")
print(message, " ", id, " ", rows, "\n")
sqlite_disconnect(db)

Output

ok 1 1