Developer beta 0.1.0-beta.1 documentation. The build is not available for download yet; these pages describe the beta as built and tested on Linux x86-64.

Quick start

1. A database directory

holadb init ./shop

A database is a directory. It holds a CATALOG (tables, columns, indexes), one engine table directory per SQL table, a TXN transaction journal, an AUTH.json once users exist, and a LOCK while a process has it open. You never edit these files by hand.

2. Schema and data, embedded

The query and shell commands open the directory directly (no server):

holadb query ./shop "
  CREATE TABLE products (sku TEXT PRIMARY KEY, name TEXT NOT NULL, price DOUBLE PRECISION, stock INT DEFAULT 0);
  CREATE INDEX products_price ON products (price);
  INSERT INTO products VALUES ('A1', 'bolt', 0.25, 500), ('B2', 'nut', 0.10, 800);
"
holadb shell ./shop
holadb> SELECT sku, price FROM products WHERE price < 0.2;
holadb> \d products
holadb> \q

Only one process may have a directory open at a time; a second one is refused with database … is in use by process N.

3. Serve it

holadb serve ./shop --listen 127.0.0.1:7433 --pg 127.0.0.1:5433 --metrics 127.0.0.1:9433
  • native protocol on 7433 (SDKs, holadb shell/query holadb://…, Studio)
  • PostgreSQL protocol on 5433 (psql, libpq drivers)
  • GET http://127.0.0.1:9433/metrics for Prometheus, /health for probes

Stop it with Ctrl-C (or a supervisor’s SIGTERM); every acknowledged write is already durable. The SDKs’ low-level clients also have a shutdown request, which needs the admin role once users exist.

4. Talk to it

psql postgresql://me@127.0.0.1:5433/holadb -c "SELECT name FROM products ORDER BY price"
holadb query holadb://127.0.0.1:7433 --json "SELECT count(*) FROM products"
holadb studio holadb://127.0.0.1:7433          # web UI on http://127.0.0.1:7480/

From a program, with the Python SDK (install it with python3 -m pip install ./rust/clients/python; the TypeScript SDK works the same way):

import holadb
with holadb.connect("holadb://127.0.0.1:7433") as db:
    for row in db.query("SELECT sku, stock FROM products WHERE stock < $1", [600]):
        print(row["sku"], row["stock"])

5. Users

A fresh database is open to whoever can reach it. Creating the first user turns authentication on and makes that user an administrator:

holadb query holadb://127.0.0.1:7433 "CREATE USER admin WITH PASSWORD 'change-me-now'"
holadb query holadb://admin:change-me-now@127.0.0.1:7433 "CREATE USER app WITH PASSWORD 'app-secret' ROLE readwrite"
psql postgresql://app@127.0.0.1:5433/holadb        # prompts for the password (SCRAM-SHA-256)

From now on every client must log in. app has the role readwrite: it reads and writes rows in every table but cannot create, alter or drop tables. Schema changes run as admin (or before the first user exists, as in step 2). A program connects as app:

import holadb
with holadb.connect("holadb://app:app-secret@127.0.0.1:7433") as db:
    db.execute("UPDATE products SET stock = stock - $1 WHERE sku = $2", [5, "A1"])
    print(db.query("SELECT stock FROM products WHERE sku = $1", ["A1"]).scalar())

The examples in Python SDK and TypeScript SDK run against exactly this setup.

6. Back up

holadb backup ./shop ./backups/shop-1          # the server must be stopped
holadb verify-backup ./backups/shop-1
holadb restore ./backups/shop-1 ./shop-copy

Backups are verified copies with a SHA-256 manifest; an interrupted backup has no manifest and is refused by restore. See Backup.

7. Import existing data

holadb migrate postgres://user:pw@host:5432/db ./shop-from-pg
holadb migrate mysql://user:pw@host:3306/db ./shop-from-mysql
holadb migrate mongodb://user:pw@host:27017/db ./shop-from-mongo --infer-schema

Every table, column, type mapping and index is reported with a ✓ or ✗; nothing is dropped or changed silently. See the migration pages.