
# Connect Sovrium to PostgreSQL

Sovrium runs on an embedded SQLite database out of the box. When you need concurrent writers, replication, or a managed database, point it at PostgreSQL — no config change, just one environment variable.

## Set DATABASE_URL

```bash
export DATABASE_URL="postgres://user:password@db.example.com:5432/mydb"
sovrium start app.ts
```

When `DATABASE_URL` is set, Sovrium selects the Postgres engine, connects, and applies your schema inside a transaction on boot. Unset it and Sovrium falls back to the zero-config SQLite default.

## Verify

The startup summary prints the active engine:

```
✓ Database: PostgreSQL (db.example.com/mydb)
```

## Next

- [Database Infrastructure](/en/docs/database-infrastructure) — how the dual-dialect engine picks SQLite vs Postgres.
- [Schema Migrations](/en/docs/migrations) — the boot-time migration that runs on connect.
- [Deploy with Docker Compose and PostgreSQL](/en/docs/deploy-docker-compose-postgres) — run both as one stack.
