Capy-Bearer Documentation

sqlite_connect

host call

Capy

function sqlite_connect(path : string) any

Description

Use sqlite_connect to open or create an SQLite database. A successful result contains the handle in value. A failed open returns no handle and closes what it opened.

A file database persists after disconnect. :memory: stores data only for that connection and creates a separate database for each open.

The connection belongs to the workspace. The runtime closes remaining connections when it destroys the workspace. Explicitly commit a transaction whose changes must persist.

Call sqlite_disconnect when you finish with the handle. A closed connection does not preserve an unfinished transaction.

Return Values

{ok: true, value: ...} on success, or {ok: false, error: "..."} on failure. The value field contains a workspace-local u64 connection handle.

Example

Capy

try connection := sqlite_connect(":memory:")
{
	print("opened\n")
	sqlite_disconnect(u64(connection))
}
else
{
	print(connection.error, "\n")
}

Output

opened