SQLite Driver Adapters
Prisma ORM provides two driver adapters for SQLite databases, each optimized for different use cases.better-sqlite3 Adapter
The@prisma/adapter-better-sqlite3 package enables usage of the better-sqlite3 driver, a fast synchronous SQLite driver for Node.js.
Installation
Usage
Constructor Options
The adapter acceptsbetter-sqlite3 configuration options:
Database URL Formats
Adapter Options
Timestamp Handling
Choose howDateTime fields are stored:
Transaction Support
The adapter uses a mutex to ensure SQLite’s single-writer constraint:Isolation Levels
SQLite only supportsSERIALIZABLE isolation level (default behavior):
Savepoints
The adapter supports nested transactions using savepoints:Migration Support
The adapter supports migrations with shadow database:Features
- Synchronous API (wrapped in Promises for adapter interface)
- Excellent performance
- Full transaction support with mutex-based concurrency control
- Savepoint support for nested transactions
- Migration support with shadow database
- Configurable timestamp formats
libSQL / Turso Adapter
The@prisma/adapter-libsql package enables usage of the @libsql/client driver for Turso and libSQL databases.
Installation
Usage - Node.js Runtime
Usage - Web Runtime
For constrained environments (edge runtimes, browsers):Configuration Options
The adapter accepts libSQL client configuration:Remote Replicas
Turso supports remote replicas for improved read performance:Embedded Replicas
Embedded replicas combine local SQLite with automatic synchronization:Connection String Formats
Transaction Support
The adapter supports transactions with automatic mutex handling:Features
- Remote database access over HTTP
- Local file and in-memory modes
- Embedded replicas with automatic sync
- Edge runtime support (Cloudflare Workers, Vercel Edge, etc.)
- Full transaction support
- Savepoints for nested transactions
Schema Migrations with Turso
Turso uses a different migration workflow. See the Turso documentation for details on:- Generating migrations with Prisma Migrate
- Applying migrations using Turso CLI
- Managing schema changes in production
Comparison
| Feature | better-sqlite3 | libSQL/Turso |
|---|---|---|
| Runtime | Node.js only | Node.js, Edge, Browser |
| Database Location | Local file only | Local, Remote, Replicas |
| Performance | Fastest (synchronous) | Fast (async, HTTP) |
| Transactions | Yes | Yes |
| Savepoints | Yes | Yes |
| Edge Runtime | No | Yes |
| Remote Database | No | Yes |
| Best For | Node.js apps, maximum performance | Serverless, edge, distributed apps |
Error Handling
Both adapters map SQLite errors to Prisma error codes:| SQLite Error Code | Prisma Code | Description |
|---|---|---|
| 19 (CONSTRAINT) | P2002 | Unique constraint violation |
| 19 (CONSTRAINT) | P2003 | Foreign key constraint violation |
| 19 (CONSTRAINT) | P2011 | Not null constraint violation |