Turso
Turso hosts SQLite databases for you. Create them in the same Stack as your Workers, and query them with Effect SQL or Drizzle.
New here? Set up credentials first, then build the tutorial.
Create a database
Section titled “Create a database”Every database lives in a group. The group decides where its databases run.
import * as Turso from "alchemy/Turso";
export const Group = Turso.Group("Group", { location: "aws-us-east-1" });
export const Db = Effect.gen(function* () { const group = yield* Group; return yield* Turso.Database("Db", { group: group.name, migrations: "./migrations", });});Each deploy runs any new migrations. See Migrations.
Query it from a Worker
Section titled “Query it from a Worker”Turso.Connect gives the Worker the database’s URL and a token. Pass it to Drizzle or Effect SQL:
const conn = yield* Turso.Connect(Db);const db = yield* Drizzle.LibSQL(conn);See Connections.
One database per tenant
Section titled “One database per tenant”Turso databases are cheap, so you can give each customer their own. Turso.ManageDatabases lets a Worker create, query, and delete databases in one group:
const tenants = yield* Turso.ManageDatabases(Tenants);const acme = yield* tenants.create("acme");const sql = yield* SQL.LibSQL(tenants.connect(acme.name));The tutorial builds this step by step. The Database per tenant guide has the details.
Where next
Section titled “Where next”- Groups and Databases
- Tokens for apps outside your Stack
- Preview databases, one copy per pull request
- Team & organization: invites, members, and settings