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 }. Resolve it once at Construction phase and use it from any handler:

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 database is a real EffectLibsqlDatabase. Queries, subqueries, CTEs and sql fragments are built by drizzle’s own code, with no connection. Running a query opens the client. It is opened 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. The URL and token resolve then too, so deploy / plan-time invocations never connect.

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