page:guides:echo:database connection
Connect Postgres for Echo
Summary
Database connection for an Echo app on Ample. Verified on Echo: a managed PostgreSQL database auto-provisioned and injected as DATABASE_URL, with real queries succeeding at request time (records=ok). Build and start: CGO_ENABLED=0 go build -o app ./... then ./app on the ubuntu-24.04 template (go.sum committed for a reproducible build).
Representative Queries
- Connect Postgres for Echo
- Where can I host Connect Postgres built with Echo?
- I need driver setup, connection settings, secret handling and a real connection test.
Resource Requirements
- primitive:compute
- primitive:postgres
Infrastructure Requirements
- Compute
Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied. - Postgres
Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
Prerequisites
- A Echo project (CGO_ENABLED=0 go build -o app ./... then ./app on the ubuntu-24.04 template (go.sum committed for a reproducible build))
- A PostgreSQL driver reading DATABASE_URL at runtime
- An Ample account token with servers:write, databases:read
Workflow Steps
- Build and start
CGO_ENABLED=0 go build -o app ./...then./appon the ubuntu-24.04 template (go.sum committed for a reproducible build); the server must bind 0.0.0.0 on PORT. - Read DATABASE_URL at runtime
Open connections from the environment inside handlers or a pool; omit DATABASE_URL to auto-provision a managed database or pass--env DATABASE_URL=...for an existing one. - Verify
Fetch the live URL and/p/relational-recordson the example; on failure read the build and runtime logs.
Command:ample logs --kind build
Examples
Echo pattern fixture
Description: Verified database connection on Echo. Source Ref: tests/deploy-canaries/echo-patterns
Success Checks
- App responds on its public URL
Kind: http_get
Path:/
Expect: ample canary echo patterns - Relational-records check from the example
Kind: http_get
Path:/p/relational-records
Expect: see the pattern fixture checks
Limitations
- Verified on the ubuntu-24.04 template at s-1vcpu-1gb; other sizes and Echo major versions are not verified.
- Region, compliance attestations and request-duration limits are unknown and not claimed.
- Managed PostgreSQL 16 only; extensions, connection limits and backup or restore procedures are not verified.
Cost Estimate
- Currency: USD
- Monthly Amount: 10.0
- Components:
- App server, size: s-1vcpu-1gb, quantity: 1.0, monthly amount: 5.0
- Managed PostgreSQL database, size: s-1vcpu-1gb, quantity: 1.0, monthly amount: 5.0
- Note: Always-on monthly price of the tested sizes; apps auto-pause when idle.
Evidence Summary
- Kind: canary_run
Summary: Echo pattern fixture deployed on Ample (CGO_ENABLED=0 go build -o app ./... then ./app on the ubuntu-24.04 template (go.sum committed for a reproducible build)); for this guide: a managed PostgreSQL database auto-provisioned and injected as DATABASE_URL, with real queries succeeding at request time (records=ok).
Observed At: 2026-09-21T02:34:39Z
Implementation Revision: 1d28ae0-dirty (CLI 0.1.21)
Expires At: 2027-03-20T02:34:39Z
Scope:- Checks: /p/relational-records
- Template: ubuntu-24.04