Module esqlcipher_nif

Low level erlang API for sqlite3 databases.

Copyright © 2011 - 2021 Maas-Maarten Zeeman, Felix Kiunke

Version: 2.0.0-rc.3

Authors: Maas-Maarten Zeeman (mmzeeman@xs4all.nl), Felix Kiunke (dev@fkiunke.de).

Description

Low level erlang API for sqlite3 databases. The actual work happens in an asynchronous low level thread that is started using start/0. These functions are implemented in native C. All functions return immediately; results are sent as a message when ready.

Data Types

bind_value()

bind_value() = sql_value() | {pos_integer() | atom(), sql_value()}

List of values for statement parameters (see bind/3).

connection()

connection() = reference()

sql()

sql() = iodata()

SQL string type.

sql_value()

sql_value() = number() | nil | iodata() | {'$blob', iodata()}

SQL value type.

statement()

statement() = reference()

Function Index

bind/5Bind parameters to a prepared statement.
changes/3Get the number of rows affected by the last update, insert, or delete statement.
close/3Close the sqlite3 connection.
column_names/4Retrieve the column names of the prepared statement.
column_types/4Retrieve the column types of the prepared statement.
exec/4Execute a query without returning any resulting rows.
get_autocommit/3Returns whether or not the database is in autocommit mode.
insert/4Execute a query, returning the last inserted row's rowid.
key/4Give the encryption key for a specified sqlite3 database.
multi_step/5Run sqlite3's step multiple times to get chunks of rows.
open/4Open the specified sqlite3 database.
prepare/4Create a prepared statement.
rekey/4Change the encryption key for a specified sqlite3 database.
reset/5Resets a prepared statement to its initial state, optionally clearing bound values.
set_update_hook/4Set an update hook that will be called for any database changes.
start/0Start a low level thread which can handle sqlite3 calls.

Function Details

bind/5

bind(Db::connection(), Stmt::statement(), Ref::reference(), Dest::pid(), Args::[bind_value()]) -> ok

Bind parameters to a prepared statement.

Returns a message of the format

ok | sqlite_error()

See also: esqlcipher:bind/3.

changes/3

changes(Db::connection(), Ref::reference(), Dest::pid()) -> ok

Get the number of rows affected by the last update, insert, or delete statement.

Returns a message of the format

{ok, integer()} | sqlite_error()

See also: esqlcipher:changes/2.

close/3

close(Db::connection(), Ref::reference(), Dest::pid()) -> ok

Close the sqlite3 connection.

Returns a message of the format

ok | sqlite_error()

See also: esqlcipher:close/2.

column_names/4

column_names(Db::connection(), Stmt::statement(), Ref::reference(), Dest::pid()) -> ok

Retrieve the column names of the prepared statement.

Returns a message of the format

{ok, [binary()]} | sqlite_error()

See also: esqlcipher:column_names/2.

column_types/4

column_types(Db::connection(), Stmt::statement(), Ref::reference(), Dest::pid()) -> ok

Retrieve the column types of the prepared statement

Returns a message of the format

{ok, [binary()]} | sqlite_error()

See also: esqlcipher:column_types/2.

exec/4

exec(Db::connection(), Ref::reference(), Dest::pid(), Sql::sql()) -> ok

Execute a query without returning any resulting rows.

Returns a message of the format

ok | sqlite_error()

See also: esqlcipher:exec/3.

get_autocommit/3

get_autocommit(Db::connection(), Ref::reference(), Dest::pid()) -> ok

Returns whether or not the database is in autocommit mode.

Returns a message of the format

boolean()

See also: esqlcipher:get_autocommit/2.

insert/4

insert(Db::connection(), Ref::reference(), Dest::pid(), Sql::sql()) -> ok

Execute a query, returning the last inserted row's rowid.

Returns a message of the format

{ok, integer()} | sqlite_error()

See also: esqlcipher:insert/3.

key/4

key(Db::connection(), Ref::reference(), Dest::pid(), Key::iodata()) -> ok

Give the encryption key for a specified sqlite3 database. Note that there will be no error if the key is wrong -- try accessing the database and look for a NOTADB error to check for that!

Returns a message of the format

ok | sqlite_error()

See also: esqlcipher:open_encrypted/3.

multi_step/5

multi_step(Db::connection(), Stmt::statement(), Chunk_Size::pos_integer(), Ref::reference(), Dest::pid()) -> ok

Run sqlite3's step multiple times to get chunks of rows. Called internally by esqlcipher:fetch_one/2, esqlcipher:fetch_chunk/3, esqlcipher:fetch_all/3 and others.

Returns a message of the format

{rows | '$done' | '$busy', [row()]} | sqlite_error() where row() is a list of values

open/4

open(Db::connection(), Ref::reference(), Dest::pid(), Filename::iodata()) -> ok

Open the specified sqlite3 database. Sends an asynchronous open command over the connection and returns ok immediately.

Returns a message of the format

ok | sqlite_error()

See also: esqlcipher:open/2, esqlcipher:open_encrypted/3.

prepare/4

prepare(Db::connection(), Ref::reference(), Dest::pid(), Sql::sql()) -> ok

Create a prepared statement

Returns a message of the format

{ok} | sqlite_error()

See also: esqlcipher:prepare/3.

rekey/4

rekey(Db::connection(), Ref::reference(), Dest::pid(), Key::iodata()) -> ok

Change the encryption key for a specified sqlite3 database. Note that this will only work once the database is decrypted, i.e. key/4 has been called. On unencrypted databases, it will silently fail/do nothing.

Returns a message of the format

ok | sqlite_error()

See also: esqlcipher:rekey/3.

reset/5

reset(Db::connection(), Stmt::statement(), Ref::reference(), Dest::pid(), ClearValues::boolean()) -> ok

Resets a prepared statement to its initial state, optionally clearing bound values.

Returns a message of the format

ok | sqlite_error()

See also: esqlcipher:reset/3.

set_update_hook/4

set_update_hook(Db::connection(), Ref::reference(), Dest::pid(), Pid::pid()) -> ok

Set an update hook that will be called for any database changes.

Returns a message of the format

ok | sqlite_error()

See also: esqlcipher:set_update_hook/3.

start/0

start() -> {ok, reference()}

Start a low level thread which can handle sqlite3 calls.

See also: esqlcipher:open/2, esqlcipher:open_encrypted/3.


Generated by EDoc