@effect/sql is a SQL toolkit for Effect that provides type-safe database access, schema validation, and integrations for PostgreSQL, MySQL, SQLite, MSSQL, and more.
Installation
Database Drivers
Install the appropriate driver for your database:PostgreSQL
MySQL
SQLite
MSSQL
ClickHouse
LibSQL
Quick Start
Query Building
Safe Interpolation
Parameters are automatically escaped:Identifiers
Quote table and column names safely:Where Clauses
Combine conditions withAND and OR:
Schema Integration
Use Effect schemas for type-safe queries:Resolvers
Build efficient data loaders with automatic batching:Migrations
Manage schema migrations with TypeScript:ORM Integrations
Drizzle
Kysely
Database Support
| Database | Package | Description |
|---|---|---|
| PostgreSQL | @effect/sql-pg | Full-featured PostgreSQL client |
| MySQL | @effect/sql-mysql2 | MySQL client using mysql2 driver |
| SQLite (Node) | @effect/sql-sqlite-node | SQLite for Node.js |
| SQLite (Bun) | @effect/sql-sqlite-bun | SQLite for Bun runtime |
| SQLite (Wasm) | @effect/sql-sqlite-wasm | SQLite in WebAssembly |
| MSSQL | @effect/sql-mssql | Microsoft SQL Server |
| ClickHouse | @effect/sql-clickhouse | ClickHouse analytics database |
| LibSQL | @effect/sql-libsql | Turso/LibSQL client |
| Cloudflare D1 | @effect/sql-d1 | Cloudflare D1 database |
Related Resources
API Reference
Complete API documentation
@effect/platform
Platform abstractions