The @sqlite module contains a single class @db, which represents a SQLite database.

Note that the version of SQLite compiled into Axiom is 3.8.9, and has the following extensions enabled:

@db Methods

:new(path) #

Create or open a SQLite database at path.

Parameters

Return

Example

db = sqlite.db('data.db') print db.schema() #print the schema print db.query('SELECT * FROM entries WHERE rowid = ?',[2]) #print row with rowid=2 :query(q,args) #

Query the database.

Parameters

Return

Notes

SQLite uses '?' as placeholder to bind arguments to query statements.

:headers(b) #

Turn headers on or off in query results.

Parameters

Notes

Headers are off by default. Headers only appear if there are 1 or more rows in the result. If there are 0 rows in the result, headers will not appear even if headers are on.

:commit() #

Commit changes to the database.

Notes

This will block until the commit actually happens (unlike Python, which fails if the database is locked and forces you to retry repeatedly).

:last_insert_rowid() #

The the rowid of the last inserted row.

Notes

Every row in every table in SQLite has a implicit nonzero integer autoincrement field called 'rowid', which can be used to uniquely identify a row within a table.

:tables(glob) #

Get all tables matching glob.

Parameters

Return

:version() #

Get the version of SQLite used.

Return

Notes

The latest version being used by Axiom is SQLite "3.8.9 2015-04-08 12:16:33 8a8ffc862e96f57aa698f93de10dee28e69f6e09".

:schema() #

Get the schema of the database.

Return

Notes

Subsequent modifications ('ALTER TABLE...') are reflected within the schema.

:indices() #

Get just the indices within the database.

Return

:eval() #

Evaluate a line like the SQLite CLI (command-line interface) does.

Parameters

Return

Notes

This is meant to be used within a REPL (read-evaluate-print loop). The parameter line can be either SQL or one of the following commands:

This imitates the behavior of the official SQLite CLI.