Skip to content
Effect Days 2026 Early bird tickets

SqliteClient

Connects Effect SQL to SQLite on Node.js using node:sqlite.

This module opens a SQLite database and exposes it as both SqliteClient and the generic Effect SQL client. It serializes access through one connection, caches prepared statements, enables WAL mode unless disabled, and waits up to five seconds for busy databases by default. Explicit transactions on writable connections use BEGIN IMMEDIATE to avoid read-to-write lock upgrades, which serializes them behind other writers even when they only read. Clients opened with readonly: true are unaffected. Busy waits block the Node.js event loop because node:sqlite is synchronous. Database backup and extension loading are supported; streaming queries and updateValues are not.

9 exports Added in v4.0.0 Source

Constructors

make

Added in v4.0.0 Source

Creates a scoped node SQLite client from the supplied configuration, using a single serialized connection with WAL and a 5-second busy timeout enabled by default. Explicit transactions on writable connections take the write lock for their duration, even when they only read; clients opened with readonly: true are unaffected.

Signature

declare function make(options: SqliteClientConfig): Effect<SqliteClient, never, any>

Layers

layer

Added in v4.0.0 Source

Builds a layer from a node SQLite client configuration, providing both SqliteClient and the generic SqlClient service.

Signature

declare function layer(config: SqliteClientConfig): Layer<any>

layerConfig

Added in v4.0.0 Source

Builds a layer from an Effect Config value, providing both the node SqliteClient service and the generic SqlClient service.

Signature

declare function layerConfig(config: Wrap<SqliteClientConfig>): Layer<any, ConfigError>

Models

BackupMetadata interface

Added in v4.0.0 Source

Metadata returned from a Node SQLite backup operation, reporting total and remaining page counts.

Signature

interface BackupMetadata {
readonly remainingPages: number;
readonly totalPages: number;
}

SqliteClientConfig interface

Added in v4.0.0 Source

Configuration for a node SQLite client backed by node:sqlite, including the database filename, read-only mode, statement cache settings, WAL and busy timeout behavior, span attributes, and query/result name transforms.

Signature

interface SqliteClientConfig {
readonly busyTimeout?: any;
readonly disableWAL?: boolean;
readonly filename: string;
readonly prepareCacheSize?: number;
readonly prepareCacheTTL?: any;
readonly readonly?: boolean;
readonly spanAttributes?: Record<string, unknown>;
readonly transformQueryNames?: (str: string) => string;
readonly transformResultNames?: (str: string) => string;
}

Services

SqliteClient

Added in v4.0.0 Source

Service tag for the node SQLite client implementation.

Signature

declare const SqliteClient: any

SqliteClient interface

Added in v4.0.0 Source

Node SQLite client service, extending SqlClient with database export, backup, and extension loading helpers. updateValues is not supported.

Signature

interface SqliteClient extends unknown {
readonly "~@effect/sql-sqlite-node/SqliteClient": "~@effect/sql-sqlite-node/SqliteClient";
readonly backup: (destination: string) => Effect<BackupMetadata, SqlError>;
readonly config: SqliteClientConfig;
readonly loadExtension: (path: string) => Effect<void, SqlError>;
readonly updateValues: never;
}

Type IDs

TypeId

Added in v4.0.0 Source

Runtime type identifier used to mark Node SqliteClient values.

Signature

declare const TypeId: TypeId

TypeId type

Added in v4.0.0 Source

Type-level identifier used to mark Node SqliteClient values.

Signature

type TypeId = "~@effect/sql-sqlite-node/SqliteClient"