PostgreSQL
Store and query relational data in a persistent PostgreSQL database.
- database
- sql
Guides: Give Claude Code a database, Run tests against real services, Connect to a database from outside
Run it
briq run postgresbriq_run({ recipe: "postgres", wait: true })curl -X POST https://api.briq.cloud/v1/briqs \
-H "Authorization: Bearer $BRIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"recipe": "postgres",
"wait": true
}'
# → { "briqs": [{ "id": "bq_…", … }], "outputs": { "DATABASE_URL": "…" }, … }
# ... when done, for each briq id
curl -X DELETE https://api.briq.cloud/v1/briqs/<id> \
-H "Authorization: Bearer $BRIQ_API_KEY"stack: app
services:
db:
recipe: postgres
# its defaults, each a field you can set:
# image: postgres:16
# size: small
# volume: { gb: 2 }Fields
| Name | Type | Options | Default |
|---|---|---|---|
| image | string | — | "postgres:16" |
| env | record | { key: string | { secret, value?, literal?, scope?, hosts?, locations? } } | {} |
| cmd | string | string[] | — | — |
| size | enum | pico, micro, nano, small, medium, large, xlarge | "small" |
| volume | object | { gb? } | {"gb":2} |
| files | record | { key: string | { base64 } } | — |
| egress | object | { hosts } | — |
Outputs
Returned by briq_run once the stack is healthy. Hosts resolve inside your team network; secrets are generated per run.
- DATABASE_URL
- postgres://postgres:<POSTGRES_PASSWORD>@db.<stack>.internal:5432/app
- PGHOST
- db.<stack>.internal
- PGPORT
- 5432
- PGUSER
- postgres
- PGPASSWORD
- <POSTGRES_PASSWORD>
- PGDATABASE
- app
What it runs
| Briq | Image | Ports | Size | Volume |
|---|---|---|---|---|
| db | postgres:16 | 5432 | small | 2 GB at /var/lib/postgresql/data |
When to use it
- Migrations, seeds or an ORM schema need a real database to be checked against.
- An integration suite expects
DATABASE_URLand you want neither mocks nor Docker. - Vector search, such as an agent's memory recalled by meaning:
image: "pgvector/pgvector:pg16", the image with pgvector. Another version is another tag:image: "postgres:17".
Tips
- Run SQL inside the briq.
DATABASE_URLis private:briq_files_puta file, thenbriq_execwithpsql -U postgres -d app -v ON_ERROR_STOP=1 -f /file.sql. nanois enough for schema checks and small fixtures.- Data survives stops, so keep the briq while iterating and destroy it at the end.
- From another briq, use
DATABASE_URLas is. - Connect from outside:
briq_exposeport 5432 withprotocol: "postgres"gives a connection string over TLS, for psql or a BI tool. See Connect to a database from outside. - No TLS inside the stack: the connection stays on the stack's private network. An app set up
to require SSL (
sslmode=require, or settings written for a hosting platform, such asssl_require=Truein Django) refuses to connect: turn that requirement off in the app's settings. - Need a bigger database? The volume starts small: set
volume: { gb: 20 }. Set it when the briq is created, and it counts toward your plan's disk.