packages/turso-cli/README.md
Turso is an embedded database engine that runs anywhere — on servers, in browsers, or on-device. It's a drop-in replacement for SQLite, rewritten in Rust for concurrent access and async I/O.
This package provides the turso CLI — an interactive SQL shell, a local sync server, and an MCP server for AI assistants.
npm install -g turso
Or run directly without installing:
npx turso
# Start an interactive shell with an in-memory database
npx turso
# Open or create a database file
npx turso myapp.db
# Execute a SQL statement directly
npx turso myapp.db "SELECT * FROM users;"
Turso is a drop-in replacement for SQLite, but adds features that SQLite doesn't have:
BEGIN CONCURRENT allows multiple writers without blocking, powered by MVCCvector32/vector64 types with distance functions (vector_distance_cos, vector_distance_l2)PRAGMA capture_data_changes_conn--mcp)--sync-server)@>, <@, ||These features are available behind --experimental-* flags:
CREATE TYPE, custom encode/decode and operatorsCREATE TRIGGER / DROP TRIGGERATTACH DATABASE / DETACH DATABASERun npx turso --help for the full list of flags.
npx turso myapp.db
turso> CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT);
turso> INSERT INTO users VALUES (1, 'Alice', '[email protected]');
turso> SELECT * FROM users;
┌────┬───────┬───────────────────┐
│ id │ name │ email │
├────┼───────┼───────────────────┤
│ 1 │ Alice │ [email protected] │
└────┴───────┴───────────────────┘
# Run a query and exit
npx turso myapp.db "SELECT count(*) FROM users;"
# Pipe-friendly list output
npx turso -q -m list myapp.db "SELECT * FROM users;"
Use Turso directly as an embedded database in your Node.js application with @tursodatabase/database:
import { connect } from "@tursodatabase/database";
const db = await connect("local.db");
await db.exec(`
CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT);
`);
const insert = db.prepare("INSERT INTO users (name, email) VALUES (?, ?)");
await insert.run(["Alice", "[email protected]"]);
const select = db.prepare("SELECT * FROM users");
console.log(await select.all());
Start a local HTTP server that implements the Turso sync protocol. The @tursodatabase/sync SDK can sync against it:
npx turso myapp.db --sync-server "0.0.0.0:8080"
Start an MCP server so AI assistants can query your databases:
npx turso --mcp
Inside the interactive shell, use .commands for database operations:
| Command | Description |
|---|---|
.open <FILE> | Open a different database |
.tables | List all tables |
.schema [TABLE] | Show table schema |
.mode <MODE> | Switch output mode (pretty, list, line) |
.import <FILE> <TABLE> | Import data from a file into a table |
.dump | Dump the database as SQL |
.quit | Exit the shell |
| Platform | Architecture |
|---|---|
| macOS | ARM64, x64 |
| Linux (glibc) | ARM64, x64 |
| Windows | x64 |
MIT