Turso Database
SQLite-compatible embedded database for modern applications, AI agents, and edge computing.
Links
Quick Navigation
| Topic | Reference |
|---|---|
| Installation | installation.md |
| Encryption | encryption.md |
| Authorization | auth.md |
| Sync | sync.md |
| Agent DBs | agents.md |
When to Use
- Embedded SQLite database with cloud sync
- AI agent state management and multi-agent coordination
- Offline-first applications
- Encrypted databases (AEGIS, AES-GCM)
- Edge computing and IoT devices
Core Concepts
libSQL
Turso is built on libSQL, an open-source fork of SQLite with:
- Native encryption (AEGIS-256, AES-GCM)
- Async I/O (Linux io_uring)
- Cloud sync capabilities
Deployment Options
- Embedded — runs locally in your app
- Turso Cloud — managed platform with branching, backups
- Hybrid — local with cloud sync (push/pull)
Common Patterns
Encrypted Database
openssl rand -hex 32 # Generate key
tursodb --experimental-encryption "file:db.db?cipher=aegis256&hexkey=YOUR_KEY"
Cloud Sync
import { connect } from "@tursodatabase/sync";
const db = await connect({
path: "./local.db",
url: "turso://...", // also accepts "libsql://..." — both schemes work
authToken: process.env.TURSO_AUTH_TOKEN,
});
await db.push(); // local → cloud
await db.pull(); // cloud → local
Agent Database
import { connect } from "@tursodatabase/database";
// Local-first
const db = await connect("agent.db");
// Or with sync
const db = await connect({
path: "agent.db",
url: "https://db.turso.io",
authToken: "...",
sync: "full",
});
Version
Based on product version: 0.7.2
Release Notes
0.7.1 – 0.7.2
- JS/serverless SDK:
transactionAsync()is the new closure-safe transaction API.transaction()is now deprecated — its closure semantics are unsound once transactions can run concurrently, because statements captured over the outerdb/conninstance can be scheduled out of order. Migrate transaction callbacks to use thetxnhandle passed intotransactionAsync()instead of closing over the outer instance (seereferences/agents.md). - Breaking:
Connection.execute()was removed from the serverless driver's native-mirroring surface (connect()), which now matches@tursodatabase/databaseand exposesrun/get/all/iterate/exec/batch/transaction(Async)instead. The libsql-compatiblecreateClient()layer keeps its ownexecute()and is unaffected (seereferences/auth.md). - Fixed a stale
inTransactionflag afterexecute()/batch()that could leave a server-side write transaction open past a constraint error. - Per-query
requestHeaders, passed through the trailing query-options argument, let you attach custom headers (e.g. a request-identity header) to a single call instead of only at the connection level. - Sync engine: the remote pull protocol (page-based WAL vs. MVCC logical-log) is now auto-detected on first contact, so the old
logical_mvcc_pullflag becomes an optional manual override instead of a requirement. A WAL-mode local replica is automatically converted to MVCC journal mode in place when it syncs against an MVCC remote. - Sync bindings (Rust, Python, JavaScript, Go, React Native) accept both
turso://andlibsql://remote URLs interchangeably. - Core fixes: an
IN (...)list query-cost regression that degradedInSeekto a full scan, a missing index left behind afterUPSERTdue to a pre-constraint-check index mutation, a change-count leak from sequences under MVCC, and DELETE/upsert replay bugs for tables with composite or non-rowid primary keys.
0.7.0
- SQL surface: SQL-standard scalar functions with PostgreSQL-compatible aliases, PostgreSQL-style sequences, MVCC-safe
AUTOINCREMENT, window-function work (row_number()on VDBE aggregate machinery,FILTERin window clauses), andWITHIN GROUPordered-set aggregates. - MVCC/durability: passive checkpoint for MVCC, portable logical-log metadata for Turso sync, and Aristo WAL verification.
- Collations: core custom collation support and locale-backed collations.
- .NET / platforms: NativeAOT static linking, remote transactions and batches, a Turso EF Core SQLite provider, NuGet native targets, and Windows ARM64 CLI releases.
Earlier (0.6.0)
JS/serverless timeouts, interactive transactions, Python SQLAlchemy improvements (sqlalchemy-libsql), npm-based CLI distribution, and a broader SQL surface for local-first/agent workloads — still in effect, see references/agents.md and references/installation.md.