lyng/lyngio/stdlib/lyng/io/db_sqlite.lyng

41 lines
1.2 KiB
Plaintext

package lyng.io.db.sqlite
import lyng.io.db
/*
SQLite provider for `lyng.io.db`.
Importing this module registers the `sqlite:` URL scheme for
`openDatabase(...)`.
Accepted generic URL forms:
- `sqlite::memory:`
- `sqlite:relative/path.db`
- `sqlite:/absolute/path.db`
Provider-specific `openDatabase(..., extraParams)` options:
- `readOnly: Bool`
- `createIfMissing: Bool`
- `foreignKeys: Bool`
- `busyTimeoutMillis: Int`
Open-time URL/config validation failures should surface as
`IllegalArgumentException`.
Runtime SQLite open failures such as opening a missing file with
`createIfMissing = false` should surface as `DatabaseException`.
SQLite provider defaults:
- `Bool` is written as `0` / `1`
- `Decimal` is written as canonical text
- `Date` is written as `YYYY-MM-DD`
- `DateTime` is written as an ISO local timestamp without timezone
- `Instant` is written as an ISO UTC timestamp with explicit timezone marker
*/
extern fun openSqlite(
path: String,
readOnly: Bool = false,
createIfMissing: Bool = true,
foreignKeys: Bool = true,
busyTimeoutMillis: Int = 5000
): Database