sqlite #

Install SQLite Dependency

Fedora 31:

sudo dnf -y install sqlite-devel

Ubuntu 20.04:

sudo apt install -y libsqlite3-dev


  • Download the source zip from SQLite Downloads
  • Create a new sqlite subfolder inside v/thirdparty
  • Extract the zip into that folder

fn connect #

fn connect(path string) ?DB

struct DB #

struct DB {
pub mut:
	is_open bool
	conn &C.sqlite3

fn (DB) @select #

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

sql expr

fn (DB) close #

fn (mut db DB) close() ?bool

close Closes the DB.
TODO: For all functions, determine whether the connection is closed first, and determine what to do if it is

fn (DB) create #

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


fn (DB) create_table #

fn (db DB) create_table(table_name string, columns []string)

fn (DB) delete #

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

fn (DB) drop #

fn (db DB) drop(table string) ?

fn (DB) error_message #

fn (db DB) error_message(code int, query string) IError

fn (DB) exec #

fn (db DB) exec(query string) ([]Row, int)

Execute the query on db, return an array of all the results, alongside any result code.
Result codes: https://www.sqlite.org/rescode.html

fn (DB) exec_none #

fn (db DB) exec_none(query string) int

In case you don't expect any result, but still want an error code e.g. INSERT INTO ... VALUES (...)

fn (DB) exec_one #

fn (db DB) exec_one(query string) ?Row

Execute a query, handle error code Return the first row from the resulting table

fn (DB) insert #

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

sql stmt

fn (DB) last_id #

fn (db DB) last_id() orm.Primitive

fn (DB) last_insert_rowid #

fn (db DB) last_insert_rowid() i64

Returns last insert rowid https://www.sqlite.org/c3ref/last_insert_rowid.html

fn (DB) q_int #

fn (db DB) q_int(query string) int

Returns a single cell with value int.

fn (DB) q_string #

fn (db DB) q_string(query string) string

Returns a single cell with value string.

fn (DB) str #

fn (db DB) str() string

fn (DB) update #

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

struct Row #

struct Row {
pub mut:
	vals []string