SQLite

data object SQLite

SQLite

Static utilities for creating or accessing SQLite databases from within an Elide-enabled application, or host-side from the Elide runtime; uses native bindings into the SQLite C API.

 

Usage

Obtain a database via the inMemory or atPath methods:

val db = SQLite.inMemory()
val db = SQLite.atPath(Path.of("my-database.db"))

Optionally, provide SQLiteCreateDatabaseOptions to configure the database:

val db = SQLite.atPath(Path.of("my-database.db"), SQLiteCreateDatabaseOptions.defaults().copy(
readonly = true,
))

 

Guest Bindings

SQLite databases are enabled for guest use by default, and can be passed without modification between guest and host code; this is also true for SQLite transactions, statements, objects, and so on.

Functions

Link copied to clipboard
fun atPath(path: Path, options: SQLiteCreateDatabaseOptions = SQLiteCreateDatabaseOptions.defaults()): SQLiteDatabase

Create a disk-backed SQLite database instance, at the provided path, and with the provided options, assuming sandbox access to I/O; if no permission is granted for I/O, an error is thrown.

fun atPath(path: Path, create: Boolean = SQLiteDatabase.DEFAULT_CREATE, readonly: Boolean = SQLiteDatabase.DEFAULT_READONLY): SQLiteDatabase

Create a disk-backed SQLite database instance, at the provided path, and with the provided options, assuming sandbox access to I/O; if no permission is granted for I/O, an error is thrown.

Link copied to clipboard

Create an in-memory database, and then de-serialize the provided data into that database instance; the returned database contains the provided data.

Link copied to clipboard
fun inMemory(readonly: Boolean = SQLiteDatabase.DEFAULT_READONLY): SQLiteDatabase

Create an in-memory database, using any of the provided options as constructor options; this method is syntactic sugar on top of inMemory with an explicit suite of options.