Home/Docs/Data

Databases

A SQLite database on Starter and Edge Pro, a Postgres database on Edge Pro, both connected to your server-rendered app, with a table editor in the dashboard.

Two kinds

SQLitePostgres
PlansStarter (1), Edge Pro (5)Edge Pro (1)
ForMost apps: forms, guest lists, small shops, blogsApps built on Postgres, Prisma or Drizzle with Postgres
Your app reaches it withdb() from the wrenship packageThe DATABASE_URL environment variable
RestoreAny minute in the last 30 daysDaily backups, kept for 7 days

Databases belong to a server-rendered project. A static site has no server code to talk to a database, so the Database tab asks you to switch to server rendering first.

Add a database

Open the project, then Database → New database, and pick SQLite or Postgres. It's ready in a few seconds.

SQLite

Your app reads it with the wrenship package, the same way in every framework:

npm install wrenship
import { db } from "wrenship/edge";

const { results } = await db().prepare("SELECT * FROM guests WHERE id = ?").bind(id).all();

db() is the database named DB; pass another name if you gave it one. The database is reachable only from your app and the dashboard, never from the internet. It works once the app is deployed on Wrenship, not during a build or in local development.

Postgres

Wrenship adds two secret environment variables to the project:

DATABASE_URL            # pooled, for your app
DATABASE_URL_UNPOOLED   # direct, for migrations

Use them with Prisma, Drizzle or any Postgres client. Redeploy after creating the database so the app picks them up. The Connection tab of the database shows the connection string, so you can connect from your own computer with psql or a database app. Connections use TLS, and every database has its own login that can't see anyone else's data.

The table editor

Database in a project gives you:

  • Tables: browse rows, sort and filter, edit cells, insert and delete rows, and create new tables. You review the SQL before it's saved, and the changes are saved together in one transaction.
  • SQL editor: run SQL against your database. It's read-only by default; switch to write mode to change data.

Backups

See Backups.