Module esqlcipher

Erlang API for sqlite3+sqlcipher databases.

Copyright © 2011 - 2017 Maas-Maarten Zeeman

Authors: Maas-Maarten Zeeman (mmzeeman@xs4all.nl).

Description

Erlang API for sqlite3+sqlcipher databases

Data Types

connection()

connection() = {connection, reference(), term()}

sql()

sql() = iodata()

statement()

statement() = {statement, term(), connection()}

Function Index

bind/2Bind values to prepared statements.
bind/3Bind values to prepared statements.
changes/1Return the number of affected rows of last statement.
changes/2Return the number of affected rows of last statement.
close/1Close the database.
close/2Close the database.
column_names/1Return the column names of the prepared statement.
column_names/2
column_types/1Return the column types of the prepared statement.
column_types/2
exec/2Execute Sql statement, returns the number of affected rows.
exec/3Execute.
fetchall/1Fetch all records.
fetchall/2Fetch all records.
fetchall/3Fetch all records.
fetchone/1
foreach/3
get_autocommit/1Get autocommit.
get_autocommit/2
insert/2Insert records, returns the last rowid.
map/3
open/1Opens a sqlite3 database mentioned in Filename.
open/2Open a database connection.
open_encrypted/2Opens an encrypted sqlcipher database connection.
open_encrypted/3Open a database connection to an encrypted database.
prepare/2Prepare a statement.
prepare/3.
q/2Execute a sql statement, returns a list with tuples.
q/3Execute statement, bind args and return a list with tuples as result.
q/4Execute statement, bind args and return a list with tuples as result restricted by timeout.
rekey/2Change database password.
rekey/3Change database password.
reset/1Reset the prepared statement back to its initial state.
set_update_hook/2Subscribe to database notifications Messages will come in the shape {action, table, id} Where action will be insert | update | delete and table will be a string and id will be an integer.
set_update_hook/3
step/1Step.
step/2.

Function Details

bind/2

bind(Stmt::prepared_statement(), Args::value_list()) -> ok | {error, error_message()}

Bind values to prepared statements

bind/3

bind(X1::prepared_statement(), Args::[], Timeout::timeout()) -> ok | {error, error_message()}

Bind values to prepared statements

changes/1

changes(Connection) -> any()

Return the number of affected rows of last statement.

changes/2

changes(X1, Timeout) -> any()

Return the number of affected rows of last statement.

close/1

close(Connection::connection()) -> ok | {error, error_message()}

Close the database

close/2

close(X1::connection(), Timeout::integer()) -> ok | {error, error_message()}

Close the database

column_names/1

column_names(Stmt::statement()) -> {atom()}

Return the column names of the prepared statement.

column_names/2

column_names(X1::statement(), Timeout::timeout()) -> {atom()}

column_types/1

column_types(Stmt::statement()) -> {atom()}

Return the column types of the prepared statement.

column_types/2

column_types(X1::statement(), Timeout::timeout()) -> {atom()}

exec/2

exec(Sql::iolist(), Connection::connection()) -> integer() | {error, error_message()}

Execute Sql statement, returns the number of affected rows.

exec/3

exec(Sql::iolist(), Params::connection(), Timeout::timeout()) -> integer() | {error, error_message()}

Execute

fetchall/1

fetchall(Statement::statement()) -> [tuple()] | {error, term()}

Statement: is prepared sql statement

Fetch all records

fetchall/2

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/3

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/1

fetchone(Statement) -> any()

foreach/3

foreach(F, Sql::sql(), Connection::connection()) -> ok

get_autocommit/1

get_autocommit(Connection::connection) -> true | false

Get autocommit

get_autocommit/2

get_autocommit(X1, Timeout) -> any()

insert/2

insert(Sql::iolist(), Connection::connection()) -> {ok, integer()} | {error, error_message()}

Insert records, returns the last rowid.

map/3

map(F, Sql::sql(), Connection::connection()) -> [Type]

open/1

open(FileName) -> {ok, connection()} | {error, term()}

Opens a sqlite3 database mentioned in Filename.

open/2

open(Filename, Timeout::timeout()) -> {ok, connection()} | {error, term()}

Open a database connection

open_encrypted/2

open_encrypted(Filename, Password) -> {ok, connection()} | {error, term()}

Opens an encrypted sqlcipher database connection

open_encrypted/3

open_encrypted(Filename, Password, Timeout::timeout()) -> {ok, connection()} | {error, term()}

Open a database connection to an encrypted database

prepare/2

prepare(Sql::iolist(), Connection::connection()) -> {ok, prepared_statement()} | {error, error_message()}

Prepare a statement

prepare/3

prepare(Sql, C, Timeout) -> any()

q/2

q(Sql::sql(), Connection::connection()) -> [tuple()] | {error, term()}

Execute a sql statement, returns a list with tuples.

q/3

q(Sql::sql(), Args::list(), Connection::connection()) -> [tuple()] | {error, term()}

Execute statement, bind args and return a list with tuples as result.

q/4

q(Sql::sql(), Args::list(), Connection::connection(), Timeout::timeout()) -> [tuple()] | {error, term()}

Execute statement, bind args and return a list with tuples as result restricted by timeout.

rekey/2

rekey(Password, Connection::connection()) -> ok

Change database password

rekey/3

rekey(Password, X2::connection(), Timeout::timeout()) -> ok

Change database password

reset/1

reset(X1::prepared_statement()) -> ok | {error, error_message()}

Reset the prepared statement back to its initial state.

set_update_hook/2

set_update_hook(Pid::pid(), Connection::connection()) -> ok | {error, term()}

Subscribe to database notifications Messages will come in the shape {action, table, id} Where action will be insert | update | delete and table will be a string and id will be an integer

set_update_hook/3

set_update_hook(Pid::pid(), X2::connection(), Timeout::timeout()) -> ok | {error, term()}

step/1

step(Stmt::prepared_statement()) -> tuple()

Step

step/2

step(X1::prepared_statement(), Timeout::timeout()) -> tuple()


Generated by EDoc