Turso

From itechmeat/llm-code · View interactive version

Turso is an AI agent skill from the GitHub repository itechmeat/llm-code. Turso SQLite database. Covers encryption, sync, serverless drivers, agent patterns. Use when working with Turso/libSQL embedded databases, configuring encryption-at-rest, setting up sync replication, choosing a Turso serverless driver for JS/Python/Rust/Go/.NET, or building agent-friendly database p

How to use this skill

Skill file

Turso Database

SQLite-compatible embedded database for modern applications, AI agents, and edge computing.

Links

Quick Navigation

| Topic | Reference |

| ------------- | --------------------------------------------- |

| Installation | installation.md |

| Quickstart | quickstart.md |

| Encryption | encryption.md |

| Authorization | auth.md |

| Sync | sync.md |

| Drivers | serverless-drivers.md |

| Agent DBs | agents.md |

When to Use

Core Concepts

libSQL

Turso is built on libSQL, an open-source fork of SQLite with:

Deployment Options

  1. Embedded — runs locally in your app
  2. Turso Cloud — managed platform with branching, backups
  3. Hybrid — local with cloud sync (push/pull)
  4. Serverless / edge — Turso Cloud over the SQL-over-HTTP protocol, no persistent connections (see references/serverless-drivers.md)

Concurrency

MVCC journal mode is selected per database with PRAGMA journal_mode = 'mvcc'. It is what allows several write transactions to run in parallel (BEGIN CONCURRENT, exposed as TransactionBehavior::Concurrent in Rust and the concurrent transaction mode in JavaScript).

Common Patterns

Encrypted Database

openssl rand -hex 32  # Generate key
tursodb --experimental-encryption "file:db.db?cipher=aegis256&hexkey=YOUR_KEY"

Serverless Connection (SQL over HTTP)

// JavaScript / TypeScript
import { connect } from "@tursodatabase/serverless";
const conn = connect({ url: process.env.TURSO_DATABASE_URL, authToken: process.env.TURSO_AUTH_TOKEN });
# Python
import turso_serverless
conn = turso_serverless.connect("libsql://my-db.turso.io", auth_token="...")
// Rust
let db = turso_serverless::Builder::new_remote(url)
    .with_auth_token(token)
    .build()
    .await?;
// Go
db, _ := sql.Open("turso-serverless", url+"?auth_token="+token)

The Rust, Go and Python drivers are new in 0.8.0; the .NET equivalent is Turso.Serverless.Client. Full matrix in references/serverless-drivers.md.

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",
});

Query Plans

EXPLAIN QUERY PLAN returns the classic four-column rows. EXPLAIN QUERY PLAN FORMAT=JSON (the clause is case-insensitive) returns one row with a single TEXT column named plan_json:

EXPLAIN QUERY PLAN FORMAT=JSON SELECT * FROM users WHERE age > 21;

The JSON document carries version, sql, result_columns, nodes and cte_materializations. nodes lists the same rows the text form prints, in the same order, with id/parent encoding the tree (parent: null marks a root) and detail holding the exact display string. Each node also has a structured op discriminated by op.type: scan, search, multi_index, index_method, hash_join, hash_build, distinct, distinct_aggregate, order_by, group_by, compound, compound_arm, list_subquery, scalar_subquery, recursive_setup, recursive_step and constant_row.

Table-access nodes may include an estimate object with the values that selected the join plan: input_rows, rows_per_input, output_rows, access_cost and total_cost. Those are planner estimates, not execution counters. The JSON format is not stable across minor versions — pin the client version if you parse it in production.

Version

Based on product version: 0.8.0

Release Highlights (0.8.0)

Release Notes

0.7.1 – 0.7.2

0.7.0

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.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.