Skip to content

vlibsql

fn blob #

fn blob(b []u8) Libsql_value_t

fn connect #

fn connect(conf Config) !DB

fn get_value_type #

fn get_value_type(val int) Libsql_type_t

fn integer #

fn integer(i i64) Libsql_value_t

VALUES

fn null #

fn null() Libsql_value_t

fn real #

fn real(f f64) Libsql_value_t

fn setup #

fn setup(config Libsql_config_t) !

UTILS

fn text #

fn text(s string) Libsql_value_t

type Libsql_config_t #

type Libsql_config_t = C.libsql_config_t

type Libsql_result_value_t #

type Libsql_result_value_t = C.libsql_result_value_t

type Libsql_slice_t #

type Libsql_slice_t = C.libsql_slice_t

type Libsql_value_t #

type Libsql_value_t = C.libsql_value_t

fn (Row) free #

unsafe
fn (mut row Row) free()

Row

fn (Row) value #

fn (row Row) value(index int) !Libsql_value_t

Get the value at the the index

fn (Row) name #

fn (row Row) name(index int) string

Get the column name at the the index

fn (Row) length #

fn (row Row) length() int

Get row column count

fn (Row) is_empty #

fn (row Row) is_empty() bool

Check if the row is empty, indicating the end of Rows.next()

fn (Rows) free #

unsafe
fn (mut rows Rows) free()

ROWS

fn (Rows) next #

fn (mut rows Rows) next() ?Row

Get the next row from rows

fn (Rows) column_name #

fn (mut rows Rows) column_name(index int) string

Get the column name at the index

fn (Rows) column_length #

fn (mut rows Rows) column_length() int

Get rows column count

fn (Statement) free #

unsafe
fn (mut stmt Statement) free()

Deallocate and close a statement

fn (Statement) execute #

fn (stmt Statement) execute() !u64

Execute a statement

fn (Statement) query #

fn (stmt Statement) query() !Rows

Query a statement

fn (Statement) reset #

fn (stmt Statement) reset()

Reset a statement

fn (Statement) bind_named #

fn (stmt Statement) bind_named(name string, val Libsql_value_t) !

Bind a named argument to a statement

fn (Statement) bind_value #

fn (stmt Statement) bind_value(val Libsql_value_t) !

Bind a positional argument to a statement

fn (Transaction) free #

unsafe
fn (mut tx Transaction) free()

internally this also calls tx.commit()

fn (Transaction) commit #

fn (tx Transaction) commit()

Deallocate and commit a transaction (transaction becomes invalid)

fn (Transaction) rollback #

fn (tx Transaction) rollback()

Deallocate and rollback a transaction (transaction becomes invalid)

fn (Transaction) prepare #

fn (tx Transaction) prepare(_sql string) !Statement

Prepare a statement in a transaction

fn (Transaction) batch #

fn (tx Transaction) batch(_sql string) !

Send a batch statement in a transaction

enum Libsql_cypher_t #

@[flags]
enum Libsql_cypher_t {
	default = 0
	aes_256
}

struct C.libsql_slice_t #

@[typedef]
struct C.libsql_slice_t {
pub:
	ptr voidptr
	len usize
}

struct C.libsql_value_t #

@[typedef]
struct C.libsql_value_t {
pub:
	value C.libsql_value_union_t
	type  int
}

struct C.libsql_value_union_t #

@[typedef]
union C.libsql_value_union_t {
pub:
	integer i64
	real    f64
	text    C.libsql_slice_t
	blob    C.libsql_slice_t
}

struct Config #

@[params]
struct Config {
pub mut:
	url                      string
	path                     string
	auth_token               string
	encryption_key           string
	sync_interval            u64
	webpki                   bool
	cypher                   Libsql_cypher_t
	disable_read_your_writes bool
}

struct Info { last_inserted_rowid i64 total_changes u64 }

struct DB #

@[heap]
struct DB {
mut:
	conn C.libsql_connection_t
	db   C.libsql_database_t
}

fn (DB) batch #

fn (db DB) batch(_sql string) !

Send a batch statement in a connection

fn (DB) create #

fn (db DB) create(table string, fields []orm.TableField) !

create is used internally by V's ORM for processing table creation queries (DDL)

fn (DB) delete #

fn (db DB) delete(table string, where orm.QueryData) !

delete is used internally by V's ORM for processing DELETE queries

fn (DB) drop #

fn (db DB) drop(table string) !

drop is used internally by V's ORM for processing table destroying queries (DDL)

fn (DB) exec #

fn (db DB) exec(_sql string) !u64

fn (DB) free #

unsafe
fn (mut db DB) free()

this will deallocate and close the connection and database

fn (DB) info #

fn (db DB) info() !(i64, u64)

Returns last_inserted_rowid and total_changes

fn (DB) insert #

fn (db DB) insert(table string, data orm.QueryData) !

insert is used internally by V's ORM for processing INSERT queries

fn (DB) last_id #

fn (db DB) last_id() int

last_id is used internally by V's ORM for post-processing INSERT queries

fn (DB) prepare #

fn (db DB) prepare(_sql string) !Statement

Prepare a statement in a connection

fn (DB) query #

fn (db DB) query(_sql string) !Rows

fn (DB) select #

fn (db DB) select(config orm.SelectConfig, data orm.QueryData, where orm.QueryData) ![][]orm.Primitive

select is used internally by V's ORM for processing SELECT queries

fn (DB) sync #

fn (db DB) sync() !Sync

Sync frames with the primary

fn (DB) transaction #

fn (db DB) transaction() !Transaction

Begin a transaction

fn (DB) update #

fn (db DB) update(table string, data orm.QueryData, where orm.QueryData) !

update is used internally by V's ORM for processing UPDATE queries