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) str #

fn (db DB) str() string

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) 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) 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_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) 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) insert #

fn (db DB) insert<T>(x T)

fn (DB) create_table #

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

struct Row #

struct Row {
pub mut:
	vals []string