Expand description
A Diesel backend for libSQL (Turso’s SQLite-compatible database).
This crate lets you use Diesel’s typed query builder, migrations, and
connection traits against local SQLite files, remote Turso databases, and
embedded replicas – all through a single LibSqlConnection type.
§Why not diesel::sqlite?
- ALTER COLUMN: libSQL extends SQLite with
ALTER TABLE ... ALTER COLUMN, exposed here viaLibSqlConnection::alter_column. - Remote Turso: connect to
libsql://URLs with auth tokens. - Embedded replicas: local reads with remote sync via
LibSqlConnection::establish_replica.
§Quick start
use diesel::prelude::*;
use diesel_libsql::LibSqlConnection;
let mut conn = LibSqlConnection::establish(":memory:")
.expect("Failed to connect");
diesel::sql_query("CREATE TABLE demo (id INTEGER PRIMARY KEY, val TEXT)")
.execute(&mut conn)
.unwrap();§Feature flags
| Flag | Description |
|---|---|
r2d2 | Sync connection pooling via r2d2 |
async | Native async connection via diesel-async |
deadpool | Async connection pooling via deadpool (implies async) |
bb8 | Async connection pooling via bb8 (implies async) |
otel | OtelInstrumentation for OpenTelemetry spans |
encryption | AES-256 encryption at rest via establish_encrypted (requires cmake) |
Structs§
- LibSql
- The LibSql backend type for Diesel.
- LibSql
Bind Collector - Bind parameter collector for LibSql queries.
- LibSql
Bind Value - A bind value for LibSql statements.
- LibSql
Connection - A Diesel connection backed by libsql.
- Replica
Builder - Builder for embedded replica connections with advanced configuration.
Enums§
- LibSql
Value - An eagerly-extracted, owned value from a libsql row.