Copyright © 2011 - 2017 Maas-Maarten Zeeman
Authors: Maas-Maarten Zeeman (mmzeeman@xs4all.nl).
cell_type() = undefined | integer() | binary() | float()
connection() = {connection, reference(), term()}
row() = tuple()
tuple of cell_type
rowid() = integer()
sql() = iodata()
statement() = {statement, term(), connection()}
bind/2 | Bind values to prepared statements. |
bind/3 | Bind values to prepared statements. |
changes/1 | Return the number of affected rows of last statement. |
changes/2 | |
close/1 | Close the database. |
close/2 | Close the database. |
column_names/1 | Return the column names of the prepared statement. |
column_names/2 | |
column_types/1 | Return the column types of the prepared statement. |
column_types/2 | |
exec/2 | Execute Sql statement. |
exec/3 | |
fetchall/1 | Fetch all records. |
fetchall/2 | Fetch all records. |
fetchall/3 | Fetch all records. |
fetchone/1 | |
flush/0 | Flush any stale answers left in the mailbox of the current process. |
foreach/3 | Execute statement and call F with each row. |
foreach/4 | Execute statement, bind args and call F with each row. |
get_autocommit/1 | Check if the connection is in auto-commit mode. |
get_autocommit/2 | Like autocommit/1, but with an extra timeout attribute. |
insert/2 | Insert records, returns the last rowid. |
map/3 | Execute statement and return a list with the result of F for each row. |
map/4 | Execute statement, bind args and return a list with the result of F for each row. |
open/1 | Opens a sqlite3 database mentioned in Filename. |
open/2 | Like open/1, but with an additional timeout. |
prepare/2 | Compile a SQL statement. |
prepare/3 | Like prepare/2, but with an extra timeout value. |
q/2 | Execute a sql statement, returns a list with tuples. |
q/3 | Execute statement, bind args and return a list with tuples as result. |
q/4 | Execute statement, bind args and return a list with tuples as result restricted by timeout. |
reset/1 | Reset the prepared statement back to its initial state. |
set_update_hook/2 | Subscribe to database notifications. |
set_update_hook/3 | Same as set_update_hook, but with an additional timeout parameter. |
step/1 | Step. |
step/2 | . |
bind(Stmt::statement(), Args::[cell_type()]) -> ok | {error, term()}
Bind values to prepared statements
bind(X1::statement(), Args::[cell_type()], Timeout::timeout()) -> ok | {error, term()}
Bind values to prepared statements
changes(Connection::connection()) -> non_neg_integer()
Return the number of affected rows of last statement.
changes(X1::connection(), Timeout::timeout()) -> non_neg_integer()
close(Connection::connection()) -> ok | {error, term()}
Close the database
close(X1::connection(), Timeout::timeout()) -> ok | {error, term()}
Close the database
column_names(Stmt::statement()) -> {atom()}
Return the column names of the prepared statement.
column_names(X1::statement(), Timeout::timeout()) -> {atom()}
column_types(Stmt::statement()) -> {atom()}
Return the column types of the prepared statement.
column_types(X1::statement(), Timeout::timeout()) -> {atom()}
exec(Sql::sql(), Connection::connection()) -> ok | {error, term()}
Execute Sql statement.
exec(Sql::sql(), Params::[cell_type()], Connection::connection()) -> ok | {error, term()}
fetchall(Statement::statement()) -> [tuple()] | {error, term()}
Statement: is prepared sql statement
Fetch all records
fetchall(Statement::statement(), ChunkSize::pos_integer()) -> [tuple()] | {error, term()}
Statement: is prepared sql statement
ChunkSize: is a count of rows to read from sqlite and send to erlang process in one bulk.
Decrease this value if rows are heavy. Default value is 5000 (DEFAULT_CHUNK_SIZE).
Fetch all records
fetchall(Statement::statement(), ChunkSize::pos_integer(), Timeout::timeout()) -> [tuple()] | {error, term()}
Statement: is prepared sql statement
ChunkSize: is a count of rows to read from sqlite and send to erlang process in one bulk.
Decrease this value if rows are heavy. Default value is 5000 (DEFAULT_CHUNK_SIZE).
Timeout: is timeout per each request of the one bulk
Fetch all records
fetchone(Statement::statement()) -> tuple()
flush() -> ok
Flush any stale answers left in the mailbox of the current process. This can happen if there has been a timeout. Normally the nif functions are called with the default 'infinite' timeout, so calling this is not needed.
foreach(F, Sql::sql(), Connection::connection()) -> ok
Execute statement and call F with each row.
foreach(F, Sql::sql(), Args::list(), Connection::connection()) -> ok
Execute statement, bind args and call F with each row.
get_autocommit(Connection::connection()) -> true | false
Check if the connection is in auto-commit mode. See: https://sqlite.org/c3ref/get_autocommit.html for more details.
get_autocommit(X1::connection(), Timeout::timeout()) -> true | false
Like autocommit/1, but with an extra timeout attribute.
insert(Sql::sql(), Connection::connection()) -> {ok, rowid()} | {error, term()}
Insert records, returns the last rowid.
map(F, Sql::sql(), Connection::connection()) -> [Type]
Execute statement and return a list with the result of F for each row.
map(F, Sql::sql(), Args::list(), Connection::connection()) -> [Type]
Execute statement, bind args and return a list with the result of F for each row.
open(Filename::string()) -> {ok, connection()} | {error, term()}
Opens a sqlite3 database mentioned in Filename.
The standard supplied sqlite3 library supports uri filenames, which makes it possible to open the connection to the database in read-only mode. More information about this can be found here: https://sqlite.org/uri.html
Example:
open("file:data.db")Opens "data.db" in the current working directory
open("file:data.db?mode=ro&cache=private")Opens "data.db" in read only mode with a private cache
open("file:memdb1?mode=memory&cache=shared")Opens a shared memory database named memdb1 with a shared cache.
open(Filename::string(), Timeout::timeout()) -> {ok, connection()} | {error, term()}
Like open/1, but with an additional timeout.
prepare(Sql::sql(), Connection::connection()) -> {ok, statement()} | {error, term()}
Compile a SQL statement. Returns a cached compiled statement which can be used in queries.
prepare(Sql::sql(), C::connection(), Timeout::timeout()) -> {ok, statement()} | {error, term()}
Like prepare/2, but with an extra timeout value.
q(Sql::sql(), Connection::connection()) -> [tuple()] | {error, term()}
Execute a sql statement, returns a list with tuples.
q(Sql::sql(), Args::list(), Connection::connection()) -> [tuple()] | {error, term()}
Execute statement, bind args and return a list with tuples as result.
q(Sql::sql(), Args::list(), Connection::connection(), Timeout::timeout()) -> [row()] | {error, term()}
Execute statement, bind args and return a list with tuples as result restricted by timeout.
reset(X1::statement()) -> ok | {error, term()}
Reset the prepared statement back to its initial state.
set_update_hook(Pid::pid(), Connection::connection()) -> ok | {error, term()}
Subscribe to database notifications. When rows are inserted deleted or updates, the process will receive messages:
{insert, string(), rowid()}When a new row has been inserted.
{delete, string(), rowid()}When a new row has been deleted.
{update, string(), rowid()}When a row has been updated.
set_update_hook(Pid::pid(), X2::connection(), Timeout::timeout()) -> ok | {error, term()}
Same as set_update_hook, but with an additional timeout parameter.
step(Stmt::statement()) -> tuple() | '$busy' | '$done'
Step
step(X1::statement(), Timeout::timeout()) -> tuple() | '$busy' | '$done'
Generated by EDoc