Docs

Databases

Real PostgreSQL and MariaDB databases on your own server, with a web console, nightly backups and an HTTPS endpoint for your code. No monthly bill and no third party.

Databases live in the Developer app. Each one runs in its own small, locked down container that Stavo makes for you: pick a name, an engine and a size, and a minute later you have a connection string.

Turn it on (admins)

  1. Add the platform sidecar to your compose file. It's the one part of Stavo that talks to Docker; the server README, "Developer platform", has the exact lines.
  2. Put the same PLATFORM_TOKEN in the server's and the sidecar's environment and restart.
  3. Open Admin > Features and turn on Managed databases (and SQL over HTTP if you want keys), for everyone or selected people.
  4. Open Admin > Developer platform to set how many databases each person gets, the largest size, memory per database, backups and local network access.

The sidecar holds the Docker socket, which is as powerful as root on the host. It only runs images from a fixed, pinned list, only touches containers it made, and every database runs as an unprivileged user with no capabilities, a read-only system, memory and CPU limits and its own private network. Docker Desktop on a Mac works.

Make a database

  1. Open Developer in the app switcher (or New > Managed database).
  2. Pick a name, PostgreSQL (17 or 16) or MariaDB (11.4, MySQL-compatible), a size limit and how many connections it may have.
  3. Optional: put it in a space so the team shares it, open it to your local network, or let the code runner reach it.

The Overview tab shows the connection details. There are two users: one that can read and write, and a read-only one for dashboards. Passwords stay hidden until you click Show, and Change password makes a new one at once.

sh
# From the code runner and services on this server
DATABASE_URL=postgresql://shop:••••@db-k3x9p2m7q4ab:5432/shop

# From your laptop, when the database is open to the local network
psql "postgresql://shop:••••@192.168.1.50:15401/shop"

The console

  • Tables: browse any table with sorting, filters and paging. Double-click a cell to change it; you see the old and new value before it's saved. Add and delete rows, export or import CSV.
  • SQL: an editor with highlighting and completion for your tables. Run everything, just the statement at the cursor, or Explain it. Results come back as a grid you can export as CSV, and your recent queries are one click away.
  • Schema: columns, types, keys, indexes and foreign keys.
  • Backups, Keys, Roles (read only) and Logs.

Console queries stop after 15 seconds and show the first 1,000 rows, so a stray SELECT * never hangs the page. People with view access to a space's database get the read-only user.

Size limits and storage

A database's size counts toward its owner's storage, like files. When it reaches its limit it turns read-only and you get a notification; delete data or raise the limit and it takes writes again. A database far past its limit is stopped until you make room.

Backups, restore and clone

Every database is backed up each night (your admin picks how many to keep), and Back up now makes one whenever you like. Backups are ordinary SQL dumps in the server's storage, so off-site backups carry them too.

  • Restore replaces the database with a backup. You type its name to confirm, and a backup of what's there now is taken first.
  • Clone makes a new database from a backup: handy for trying a migration on a copy.
  • Export .sql and Import .sql move a database in and out of Stavo.

Query over HTTPS

With SQL over HTTP on, make a key in the Keys tab (read only, or read and write) and send queries to/api/v1/sql/<database>. It works from servers, edge functions and the browser, and through Cloudflare Tunnel. Values are sent as parameters, never pasted into the SQL.

js
import { stavoSql } from "https://drive.example.com/sdk/stavo-sql.js";

const sql = stavoSql("https://drive.example.com/api/v1/sql/k3x9p2m7q4ab", process.env.STAVO_SQL_KEY);
const orders = await sql`SELECT * FROM orders WHERE customer = ${id}`;
await sql.transaction([
  sql`INSERT INTO orders (customer) VALUES (${id})`,
  sql`UPDATE customers SET orders = orders + 1 WHERE id = ${id}`,
]);
sh
curl https://drive.example.com/api/v1/sql/k3x9p2m7q4ab \
  -H "Authorization: Bearer stsql_…" -H "Content-Type: application/json" \
  -d '{"query": "SELECT count(*) AS n FROM orders WHERE total > $1", "params": [100]}'

Answers are JSON (rows, fields, rowCount). A list of queries runs as one transaction. Each key has its own rate limit, and revoking it stops it right away.

Your Stavo Databases, as SQL

The Databases in your Drive (the ones in Notes, with views) can be queried with SQL too, read only: open Developer > Query with SQL. Each database is a table named after it (Reading list becomes reading_list), with a column per property.

  • Numbers are numbers, checkboxes are true or false, dates are text you can sort (plus an _end column for ranges).
  • Selects show the option's name; multi-selects, people, files and relations are JSON lists.
  • Every table has _id, _created and _edited; _databases lists them all.

For Grafana or Metabase, turn on Mirror Stavo Databases on a PostgreSQL database: the same tables appear in its stavo_stdb schema and stay in step as you edit. Connect the tool with the read-only user.

In the code editor

The IDE has a Databases view with your databases, tables and columns. Double-click a table to peek at its rows, or right-click a database and choose Insert as DATABASE_URL in .env: the connection string goes in the folder's .env, and code you run in the terminal connects straight away.

Questions

Can other people on the server see my database?

No. Only you, or the members of the space it's in. Admins can stop or start it, but not open it.

Why one container per database?

Each one gets its own memory, CPU and version, and a problem in one never touches another. Small databases use little memory when they're idle.

Do I get a superuser?

No. Your user owns its database and everything in it, which covers tables, views, functions and most extensions that don't need a superuser.

Is it on the internet?

Never directly. Databases sit on private networks. The HTTPS endpoint goes through Stavo with a key, and local network access is a single port your admin allows.