Database
Every project comes with a PostgreSQL database. Use it from your worker as env.db — no connection string, no secrets.
{ "database": true }runlot deployAfter the deploy, env.db is available in your worker. The database runs on the same machine as your app and is reached through a binding, so there is no connection string to store as a secret.
const rows = await env.db.exec("select id, name from users where id = $1", [1]);One database per project
There is no database name to choose, so the binding is always env.db. If you need more than one database, split the work into separate projects.
Pages in this section
Getting started
- env.db — the four APIs you use from a worker
- Your first query — from creating a table to reading rows back
- @runlot/pg — a
Poolthat behaves like node-postgres
Operating
- ORMs — Prisma, Drizzle, Kysely, TypeORM, Sequelize, Knex
- Connecting with psql and the PostgreSQL protocol
- pg token — short-lived credentials for machines
- Migrations
- Backup and restore
Reference
- The 150 MB cap
- Sessions — why every call opens a new session
- Transactions
- Extensions