ScriptsApr 12, 2026·1 min read

libSQL (Turso) — Open-Contribution Fork of SQLite

libSQL is a fork of SQLite that is both open source and open to contributions. Created by Turso to add features SQLite cannot: embedded replicas, server mode, vector search, and ALTER TABLE extensions. The edge database for modern apps.

SC
Script Depot · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

# Install Turso CLI
brew install tursodatabase/tap/turso

# Create database
turso db create mydb
turso db shell mydb

# Or run libSQL locally
docker run -d --name libsql -p 8080:8080 ghcr.io/tursodatabase/libsql-server:latest

SQL usage (SQLite-compatible + extensions):

CREATE TABLE assets (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  repo TEXT NOT NULL UNIQUE,
  stars INTEGER DEFAULT 0,
  embedding F32_BLOB(384),  -- vector column
  created_at TEXT DEFAULT (datetime("now"))
);

INSERT INTO assets (repo, stars) VALUES ("react", 230000);
INSERT INTO assets (repo, stars) VALUES ("vue", 210000);

SELECT * FROM assets ORDER BY stars DESC;

-- Vector search (libSQL extension)
SELECT repo, vector_distance_cos(embedding, vector("[0.1, 0.2, ...]")) AS distance
FROM assets
ORDER BY distance ASC
LIMIT 5;

-- ALTER TABLE ADD COLUMN (SQLite limitation removed in libSQL)
ALTER TABLE assets ADD COLUMN category TEXT DEFAULT "general";

TypeScript client:

import { createClient } from "@libsql/client";

const db = createClient({
  url: "libsql://mydb-william.turso.io",
  authToken: "...",
});

const result = await db.execute("SELECT * FROM assets ORDER BY stars DESC LIMIT 10");
console.log(result.rows);
Intro

libSQL is a fork of SQLite that is both open source (MIT) and open to community contributions. Created by the Turso team because SQLite is open source but does not accept external contributions. libSQL adds features that SQLite has historically refused: server mode, embedded replicas, vector search (via vectorlite), ALTER TABLE extensions, and encryption at rest. Turso provides a managed edge database service built on libSQL.

What libSQL Does

  • SQLite compatible — full SQLite API and file format
  • Server mode — HTTP and WebSocket access (sqld)
  • Embedded replicas — local SQLite file synced from remote
  • Vector search — F32_BLOB type + vector distance functions
  • ALTER TABLE — DROP COLUMN and other extensions
  • Encryption — at-rest encryption
  • Multi-tenancy — schema-based namespace isolation
  • Edge deployment — replicas at edge locations
  • TypeScript/Rust/Go/Python clients — official SDKs
  • Turso managed — global edge DB service

Architecture

Fork of SQLite C codebase with extensions. sqld (server daemon) wraps libSQL and serves HTTP/WebSocket/gRPC. Embedded replicas sync WAL frames from primary to local SQLite file on the client. Turso infrastructure distributes replicas globally via Fly.io.

Self-Hosting

# Run sqld server
docker run -d --name libsql -p 8080:8080 \
  -v libsql-data:/var/lib/sqld \
  ghcr.io/tursodatabase/libsql-server:latest

# Connect
curl http://localhost:8080/v2/pipeline -d "{\"requests\": [{\"type\": \"execute\", \"stmt\": {\"sql\": \"SELECT 1\"}}]}"

Key Features

  • Full SQLite compatibility
  • Server mode (HTTP + WebSocket)
  • Embedded replicas
  • Vector search
  • ALTER TABLE extensions
  • Encryption at rest
  • Multi-tenancy
  • Edge deployment (Turso)
  • Official SDKs (TS, Rust, Go, Python)
  • Open to contributions (unlike SQLite)

Comparison

Database Type Server Mode Vector
libSQL SQLite fork Yes (sqld) Yes
SQLite Embedded No No
LiteFS SQLite replication Proxy No
Cloudflare D1 SQLite managed Yes No
PlanetScale MySQL managed Yes No
Neon Postgres managed Yes Via pgvector

常见问题 FAQ

Q: 和 SQLite 区别? A: libSQL 是 SQLite 的超集。增加了 server 模式、embedded replicas、向量搜索、ALTER TABLE 扩展。SQLite 原项目不接受外部贡献,libSQL 完全开放。

Q: Turso 是什么? A: Turso 是基于 libSQL 的托管 edge 数据库服务。数据库副本部署在全球边缘节点(Fly.io),读延迟<50ms。免费层每月 9GB 存储 + 500 DB。

Q: 适合什么场景? A: 需要 SQLite 简单性但又需要远程访问、多副本、或向量搜索的场景。如 SaaS multi-tenant、移动 app 本地缓存 + 云同步、edge worker 数据层。

来源与致谢 Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets