Skip to content

Drizzle.LibSQL reference

Source: packages/drizzle/src/LibSQL.ts

Open a Drizzle database over a libSQL database (e.g. Turso) using the drizzle-orm/effect-libsql integration.

Accepts the client returned by Turso.Connect(db) — or any { url, authToken } — and returns a chainable Proxy over EffectLibsqlDatabase (via proxyChain): every property read records a step, every call records args, and the chain is replayed against the resolved drizzle db when it’s finally yielded as an Effect. Callers don’t need a separate yield* conn step:

const conn = yield* Turso.Connect(Db);
const db = yield* Drizzle.LibSQL(conn, { relations });
fetch: Effect.gen(function* () {
const rows = yield* db.select().from(users);
});

The client is built lazily on the first query and memoized on the current execution’s Scope (via makeExecutionMemo), so it is created at most once per execution — a Worker fetch/queue/scheduled event, a Durable Object call, a Workflow run, or a Lambda invocation — and closed when that execution settles. Resolving the URL and token is likewise deferred, so deploy / plan-time invocations never connect.

@effect/sql-libsql client options (e.g. intMode) are passed via config.client.