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
- 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 withtelbase db create --project my-app. - It creates the schema and loads the data the app ships with, through
telbase db run(below). - 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.
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'sdrizzle-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:
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
# 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.sqlWrite queries
# 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.sqlInteractive session (PostgreSQL)
# Opens a psql session connected to your database
telbase db connect --project my-appBackups
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.
# 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.sqlPostgreSQL Extensions
Enable popular PostgreSQL extensions directly from the CLI. Telbase supports pgvector, pg_trgm, PostGIS, and uuid-ossp.
# List available extensions
telbase db extensions
# Enable pgvector for AI embeddings
telbase db enable-extension pgvectorEmbedding presets
When enabling pgvector, use a preset to auto-configure the vector dimensions and create a sample embeddings table:
# 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-tableAvailable 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-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:
# 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
- Quick Start — deploy your first app
- Using with Claude Code — how the agent sets up an app's database
- CLI Reference — full
dbcommand reference with all flags - Guides & Articles — schema patterns, best practices, and more