Class sqlite3
Lightweight SQLite database interface
This module is only available from web process Lua states.
This module provides Lua access to SQLite databases. These are used for a number of purposes by the default modules, including storing user bookmarks, cookies, and browsing history.
Opening a database
To create a new sqlite3
instance and connect to a database, use the
sqlite3
constructor:
local db = sqlite3{ filename = "path/to/database.db" }
Methods
sqlite3:exec (query, bindings)
Compile and execute the SQL query string query
against the database.
The sqlite3
instance must have been opened successfully.
Parameters
-
queryType: stringA SQL query, comprised of one or more SQL statements.
-
bindingsType: tableOptionalDefault:
{}
A table of values to bind to each SQL statement.
Return Values
-
tableA table representing the query result.
sqlite3:close ()
Close a database and release related resources.
sqlite3:compile (statement)
Compile a SQL statement into a newly-created sqlite3::statement
instance.
Parameters
-
statementType: stringA SQL statement.
Return Values
-
sqlite3::statementA newly-created instance representing a compiled statement.
sqlite3:changes ()
Get the number of rows that were added, removed, or changed by the
most recently executed INSERT
, UPDATE
or DELETE
statement.
Return Values
-
numberThe number of modified rows.
Properties
sqlite3.filename
Type: string
Read-only
The path to the database that the
sqlite3
instance is connected to.
Attribution
Copyright
- 2011 Mason Larobina