Databases

Each app can have a hosted PostgreSQL or SQLite database of its own. You need no database account: Telbase creates it, and your agent sets it up with the app's own tooling.

How It Works

  1. The agent registers the app with its database: telbase apps create my-app --provider vercel --database postgres (or --database sqlite). An app registered without one gets one later with telbase db create --project my-app.
  2. It creates the schema and loads the data the app ships with, through telbase db run (below).
  3. It sets the running app's connection string on the provider, from a command, never through a file.

A SQLite app stays on SQLite and a PostgreSQL app on PostgreSQL. The plan counts both alike.

Customer-facing terms
Telbase uses SQLite and PostgreSQL in all user-facing contexts. The underlying providers (Turso for SQLite, Neon for PostgreSQL) are transparent to you.

SQLite vs PostgreSQL

A SQLite file does not survive on Vercel or Cloud Run: the disk is temporary. Telbase hosts SQLite databases instead, reached over libSQL.

  • Works with any compute provider (Vercel, Cloud Run)
  • Drivers that speak libSQL need no code change: @libsql/client, Drizzle's drizzle-orm/libsql, Prisma's @prisma/adapter-libsql
  • The running app gets the URL and a token of its own
  • Ideal for: dashboards, approval workflows, trackers, CRUD apps

Migrations

Vercel and Cloud Run do not run migrations for you. telbase db run runs one command with DATABASE_URL set to the direct URL, and writes nothing to disk:

bash
telbase db run my-app -- npx prisma migrate deploy
telbase db run my-app -- npx drizzle-kit migrate
telbase db run my-app -- alembic upgrade head
telbase db run my-app -- python manage.py migrate
telbase db run my-app -- npm run seed

--env NAME sets another variable name, and --format jdbc|npgsql|asyncpg gives the shape the driver needs. For SQLite, db run also sets DATABASE_AUTH_TOKEN, TURSO_DATABASE_URL and TURSO_AUTH_TOKEN.

Querying Your Database

Run SQL directly from the CLI. Useful for debugging, data inspection, and one-off queries.

Read-only queries

bash
# SELECT, WITH, and EXPLAIN queries (max 1,000 rows)
telbase db query --project my-app "SELECT count(*) FROM users"

# From a file
telbase db query --project my-app --file analytics.sql

Write queries

bash
# INSERT, UPDATE, DELETE, CREATE TABLE, ALTER TABLE
telbase db exec --project my-app "UPDATE users SET role = 'admin' WHERE email = '[email protected]'"

# From a file
telbase db exec --project my-app --file seed.sql

Interactive session (PostgreSQL)

bash
# Opens a psql session connected to your database
telbase db connect --project my-app

Backups

Telbase does not yet create, list or restore database backups on any plan. Until it does, take your own backups: print the connection string with telbase db url <app> and export with your database's own tools.

bash
# PostgreSQL: full logical backup
pg_dump "$(telbase db url my-app)" > backup.sql

# Restore into the same database
psql "$(telbase db url my-app)" < backup.sql
No managed backups yet
The only safety net today is the provider's own short point-in-time history, which Telbase does not configure or expose. Treat your export as the backup.

PostgreSQL Extensions

Enable popular PostgreSQL extensions directly from the CLI. Telbase supports pgvector, pg_trgm, PostGIS, and uuid-ossp.

bash
# List available extensions
telbase db extensions

# Enable pgvector for AI embeddings
telbase db enable-extension pgvector

Embedding presets

When enabling pgvector, use a preset to auto-configure the vector dimensions and create a sample embeddings table:

bash
# OpenAI text-embedding-3-small (1536 dimensions)
telbase db enable-extension pgvector --preset openai-3-small --create-table

# OpenAI text-embedding-3-large (3072 dimensions)
telbase db enable-extension pgvector --preset openai-3-large --create-table

# Voyage AI embeddings (1024 dimensions)
telbase db enable-extension pgvector --preset claude --create-table

# Custom dimensions
telbase db enable-extension pgvector --dimensions 384 --create-table

Available presets: openai-ada-002, openai-3-small, openai-3-large, claude, cohere-english, sentence-transformers.

For a complete guide on embedding presets and RAG applications, see Vector Search & RAG.

Index configuration
By default, pgvector creates an HNSW index with cosine distance. You can customize with --index-type (hnsw, ivfflat, none) and --metric (cosine, l2, inner_product).

Environment Variables

The running app reads its connection string from its provider. The agent sets it from a command, under the name the app reads:

bash
# PostgreSQL on Vercel: the pooled URL
telbase db url my-app --pooled | telbase vercel env add DATABASE_URL production

# SQLite on Vercel: the URL and a token of its own
telbase db url my-app | telbase vercel env add DATABASE_URL production
telbase db url my-app --token | telbase vercel env add DATABASE_AUTH_TOKEN production

# Cloud Run: on the deploy command
--update-env-vars DATABASE_URL="$(telbase db url my-app --pooled)"

Next Steps