Ecto adapter for LibSQL and Turso databases.
This adapter provides full Ecto support for LibSQL databases, including local SQLite files, remote Turso cloud databases, and embedded replicas that sync between local and remote.
Connection Modes
The adapter automatically detects the connection mode based on configuration:
- Local: Only
:databasespecified - uses local SQLite file - Remote:
:uriand:auth_tokenspecified - connects directly to Turso - Remote Replica: All of
:database,:uri,:auth_token, and:syncspecified - maintains local copy with automatic sync to remote
Configuration Examples
Local Database
config :my_app, MyApp.Repo,
adapter: Ecto.Adapters.LibSql,
database: "my_app.db"Remote Turso Database
config :my_app, MyApp.Repo,
adapter: Ecto.Adapters.LibSql,
uri: "libsql://your-database.turso.io",
auth_token: "your-auth-token"Embedded Replica (Local + Remote Sync)
config :my_app, MyApp.Repo,
adapter: Ecto.Adapters.LibSql,
database: "replica.db",
uri: "libsql://your-database.turso.io",
auth_token: "your-auth-token",
sync: trueWith Encryption
config :my_app, MyApp.Repo,
adapter: Ecto.Adapters.LibSql,
database: "encrypted.db",
encryption_key: "your-secret-key-must-be-at-least-32-characters"Configuration Options
:database- Path to local SQLite database file:uri- Remote LibSQL server URI (e.g.,"libsql://your-db.turso.io"):auth_token- Authentication token for remote connections:sync- Enable automatic sync for embedded replicas (boolean, default:truewhen in replica mode):encryption_key- Encryption key for local database (minimum 32 characters)
Features
- Full Ecto query support (schemas, changesets, associations, etc.)
- Migration support with DDL transactions
- SQLite-compatible data types with Ecto type conversions
- Constraint violation detection and error handling
- Storage management (
mix ecto.create,mix ecto.drop, etc.) - Structure dump/load support
Limitations
- No advisory locking for migrations (SQLite uses database-level locking)
Repo.stream/2is not yet implemented (use DBConnection cursor interface instead)- Some advanced PostgreSQL/MySQL features may not be available
- Vector search requires LibSQL-specific syntax