51sqlite3 Module
51.1Overview
The sqlite3
module provides measures to access SQLite3 database. To utilize it, import the sqlite3
module using import
function.
51.2sqlite3.db Class
51.2.1Constructor
sqlite3.db(filename:string) {block?}
Opens an sqlite3 database file and returns a connection handle with the database.
If block
is specified, it would be evaluated with a block parameter |db:sqlite3|
, where db
is the created instance. In this case, the block's result would become the function's returned value. The connection handle will be automatically closed when the block finishes.
51.2.2Method
sqlite3.db#close()
sqlite3.db#exec(sql:string):map
list
that has list
instances containing queried result as its elements.
sqlite3.db#getcolnames(sql:string):map {block?}
sqlite3.db#query(sql:string):map {block?}
Executes an SQL statement and creates an iterator
that returns list
instances containing queried result as its elements.
You should use sqlite3.db#query()
instead of sqlite3.db#exec()
when it's likely that you get a large size of data as the result.
sqlite3.db#transaction() {block}
Executes the block within a transaction. The process is like following:
- Executes a sqlit3 command 'BEGIN TRANSACTION'.
- Executes code in the
block
. - Executes a sqlite3 command 'END TRANSACTION'.
51.3Thanks
This module uses SQlite3 library which is distributed in the following site: