View Source Exqlite.Sqlite3 (Exqlite v0.24.0)
The interface to the NIF implementation.
Summary
Functions
Get the number of changes recently.
Closes the database and releases any underlying resources.
Disconnect from database and then reopen as an in-memory database based on the serialized binary.
Allow loading native extensions.
Executes an sql script. Multiple stanzas can be passed at once.
Interrupt a long-running query.
Opens a new sqlite database at the Path provided.
Once finished with the prepared statement, call this to release the underlying resources.
Serialize the contents of the database to a binary.
Send log messages to a process.
Send data change notifications to a process.
Causes the database connection to free as much memory as it can. This is useful if you are on a memory restricted system.
Types
Functions
Get the number of changes recently.
Note: If triggers are used, the count may be larger than expected.
Closes the database and releases any underlying resources.
Disconnect from database and then reopen as an in-memory database based on the serialized binary.
Allow loading native extensions.
Executes an sql script. Multiple stanzas can be passed at once.
Interrupt a long-running query.
Opens a new sqlite database at the Path provided.
path
can be ":memory"
to keep the sqlite database in memory.
Options
:mode
- use:readwrite
to open the database for reading and writing ,:readonly
to open it in read-only mode or[:readonly | :readwrite, :nomutex]
to open it with no mutex mode.:readwrite
will also create the database if it doesn't already exist. Defaults to:readwrite
. Note: [:readwrite, :nomutex] is not recommended.
Once finished with the prepared statement, call this to release the underlying resources.
This should be called whenever you are done operating with the prepared statement. If the system has a high load the garbage collector may not clean up the prepared statements in a timely manner and causing higher than normal levels of memory pressure.
If you are operating on limited memory capacity systems, definitely call this.
Serialize the contents of the database to a binary.
Send log messages to a process.
Each time a message is logged in SQLite a message will be sent to the pid provided as the argument.
The message is of the form: {:log, rc, message}
, where:
rc
is an integer result code or an extended result codemessage
is a string representing the log message
See SQLITE_CONFIG_LOG
and
"The Error And Warning Log" for more details.
Restrictions
- Only one pid can listen to the log messages at a time. If this function is called multiple times, only the last pid will receive the notifications
Send data change notifications to a process.
Each time an insert, update, or delete is performed on the connection provided as the first argument, a message will be sent to the pid provided as the second argument.
The message is of the form: {action, db_name, table, row_id}
, where:
action
is one of:insert
,:update
or:delete
db_name
is a string representing the database name where the change took placetable
is a string representing the table name where the change took placerow_id
is an integer representing the unique row id assigned by SQLite
Restrictions
- There are some conditions where the update hook will not be invoked by SQLite. See the documentation for more details
- Only one pid can listen to the changes on a given database connection at a time. If this function is called multiple times for the same connection, only the last pid will receive the notifications
- Updates only happen for the connection that is opened. For example, there are two connections A and B. When an update happens on connection B, the hook set for connection A will not receive the update, but the hook for connection B will receive the update.
Causes the database connection to free as much memory as it can. This is useful if you are on a memory restricted system.
@spec transaction_status(db()) :: {:ok, :idle | :transaction}