SQLite Drivers
Drizzle ORM supports SQLite through multiple drivers optimized for different JavaScript runtimes and deployment environments.better-sqlite3
Synchronous SQLite driver for Node.js with excellent performance.Installation
Basic Usage
Database Options
Performance Optimizations
WAL Mode (Write-Ahead Logging)
WAL mode significantly improves write performance and allows concurrent reads during writes.
Accessing the Client
libSQL (Turso)
Driver for libSQL databases, including Turso’s edge database platform.Installation
Basic Usage
Embedded Replicas (Hybrid)
Combine local SQLite with remote Turso database for optimal performance:Environment Variables (Turso)
Get these from your Turso dashboard:Advanced Options
Cloudflare D1
SQLite driver for Cloudflare Workers and Pages.Installation
Basic Usage
Worker Configuration
In yourwrangler.toml:
Batch Queries
D1 supports efficient batch operations:Local Development
Choosing a Driver
- Node.js
- Distributed/Edge
- Cloudflare Workers
Recommended: better-sqlite3
- Synchronous API (simpler code)
- Excellent performance
- Full SQLite feature support
- Native Node.js addon