ciallo-driver-sqlite

    Production SQLite driver (Native vendored sqlite3 WAL C FFI + Node node:sqlite / Bun bun:sqlite, 1-Writer + N-Readers pool) for unmbt/ciallo-orm

    sqlite
    sqlite3
    wal
    orm
    driver
    ciallo
    Download zip
    Author
    Version
    0.2.0
    License
    MIT
    Last updated
    5 hours ago
    Downloads
    1

    #unmbt/ciallo-driver-sqlite

    Production SQLite SqlDriver for unmbt/ciallo-orm:

    • Native target: C FFI over vendored public-domain SQLite3 amalgamation (sqlite3.c), enabling PRAGMA journal_mode = WAL, synchronous = NORMAL, foreign_keys = ON, and busy_timeout = 5000
    • JavaScript target: Zero-dependency runtime auto-detection (bun:sqlite on Bun, node:sqlite DatabaseSync on Node.js 22.5+)
    • 1-Writer + N-Readers pool: Serializes write statements and transactions while serving concurrent read queries through a dedicated read-only pool
    • Extended error code mapping: Maps SQLITE_CONSTRAINT_UNIQUE (2067) / PRIMARYKEY (1555) to DataError::UniqueViolation and SQLITE_CONSTRAINT_FOREIGNKEY (787) to DataError::ForeignKeyViolation

    SqliteConfig

    pub(all) struct SqliteConfig {
    path : String
    wal_mode : Bool
    synchronous : String
    foreign_keys : Bool
    busy_timeout_ms : Int
    reader_pool_size : Int
    acquire_timeout_ms : Int
    } derive(Eq,
    Debug
    )

    SQLite production configuration (WAL mode, busy timeout, foreign keys, 1-Writer + N-Readers pool).

    SqliteConfig::SqliteConfig

    fn SqliteConfig::SqliteConfig(path? : String, wal_mode? : Bool, synchronous? : String, foreign_keys? : Bool, busy_timeout_ms? : Int, reader_pool_size? : Int, acquire_timeout_ms? : Int) -> SqliteConfig

    SqliteConfig::in_memory

    fn SqliteConfig::in_memory() -> SqliteConfig

    SqliteConfig::is_memory

    fn SqliteConfig::is_memory(self : SqliteConfig) -> Bool

    SqliteDriver

    pub struct SqliteDriver {
    // private fields
    }

    Production SQLite SqlDriver implementing 1 Writer + N Readers WAL read/write split (and unified single connection for :memory: databases).

    SqliteDriver::close

    async fn SqliteDriver::close(self : SqliteDriver) -> Unit

    SqliteDriver::open

    Opens a SQLite driver configured with WAL mode, synchronous = NORMAL, foreign_keys = ON, and busy_timeout. File-backed databases use 1 Writer + N Readers; :memory: uses 1 shared connection.

    SqliteDriver::open_memory

    Opens an in-memory SQLite database (:memory:) with foreign_keys = ON.

    SqliteDriver::reader_stats

    SqliteDriver::writer_stats

    is_read_only_sql

    fn is_read_only_sql(sql : StringView) -> Bool

    Determines whether a SQL statement is safely read-only and eligible for the Reader pool.

    map_sqlite_error

    fn map_sqlite_error(ext_code : Int, message : String) ->
    DataError

    Maps SQLite extended error codes (e.g. 2067 UNIQUE, 1555 PRIMARYKEY, 787 FOREIGNKEY) and fallback error messages into structured @codec.DataError.