SQLiteDatabase
SQLite Database
Describes the concept of a database as driven by the SQLite engine; SQLite databases can be held in-memory, or backed by a file which is persisted to disk.
The SQLiteDatabase is the primary interface through which all database operations are performed, including queries, transactions, and schema operations.
Database Lifecycle
There are essentially three phases to a SQLite database as understood by Elide: initialized, opened, and closed.
When the database is in an initialized state, it has not yet loaded data from disk or memory (via serialization).
Initialization takes place immediately when the database object is created, and is guided by the configuration parameters which can be provided to the constructor.
The database moves almost immediately to an opened state, where it is ready to accept queries, transactions, or deserialization from in-memory data.
When the database is closed (via the close method), all associated resources are freed, and the database may no longer be used for queries or transactions of any kind; such transactions (placed after close) throw unconditional exceptions.
Managed Resources
All resources associated with a given SQLite database are managed by that database; this includes query ephemeral, like prepared statements, transactions, and associated objects.
When a database is closed, this tree of objects is closed (where applicable) in a reasonable order.
After closing, resources are freed, with the only exception being result objects de-serialized for use in the user's application.
These objects remain alive so long as the user's application maintains references to them; database references held by ephemeral objects are always weakly referenced.
Guest Usage
SQLite leverages a constrained set of primitive data types (see SQLitePrimitiveType) to represent data within user tables; as a result, SQLite data types work well with guest code out of the box.
Wrapping and boxing types, where required, use proxy interfaces so that they interoperate as expected with guest code; by and large, Elide's SQLite API for guests follows Bun's API in JavaScript.
See also
Module-level SQLite API
Statement API
Transaction API
Transactor Interface
SQLite Types
Properties
Functions
Obtain the underlying SQLite JDBC connection; this method is provided for host-side use only.
Load a native extension into the SQLite engine context managed by this database proxy; the extension is loaded via the native interface for SQLite.
Parse a query statement for execution; the resulting statement can be used multiple times, with intelligent caching for re-use.
Serialize the current database into a raw array of bytes; the resulting bytes can be persisted to disk, or sent across a network connection, and de-serialized into an equivalently behaving database object at a later time or on another peer.
Execute the provided runnable transaction function against the current SQLite database, applying recovery and exclusion logic where applicable; the return value R yielded by the transaction function is returned to the caller, via the resolution of the provided SQLiteTransaction.