PostgreSQL
Deploy PostgreSQL 17 with persistent storage — one command, auto-generated credentials
Ink deploys PostgreSQL 17 as a container service with a persistent volume. Your agent provisions the database using a template — credentials are auto-generated and returned immediately.
Deploying
Your agent uses the template_deploy MCP tool:
template_deploy(
"template": "postgresql",
"name": "my-db"
){
"services": [object Object],
"outputs": [object Object]
}Or via the CLI:
ink template deploy postgresql --name my-dbAuto-generated credentials
| Variable | Value |
|---|---|
POSTGRES_USER | postgres |
POSTGRES_PASSWORD | Auto-generated at deploy time |
POSTGRES_DB | railway |
Passwords are randomly generated. The agent receives them as outputs — no manual password management required.
Persistent storage
A persistent volume is attached at /var/lib/postgresql/data (1 Gi default). Data survives container restarts and redeployments.
Connecting
After deployment, template_deploy returns a DATABASE_URL in the format:
postgresql://user:pass@hostname:5432/dbnameThe internal URL (my-db:5432) is used for service-to-service communication within the same project. Any sibling service can connect by hostname — no external networking required.
Client libraries
Node.js
npm install pgimport pg from 'pg';
const pool = new pg.Pool({
connectionString: process.env.DATABASE_URL,
});
const result = await pool.query('SELECT * FROM users');Python
pip install psycopg2-binaryimport os
import psycopg2
conn = psycopg2.connect(os.environ["DATABASE_URL"])
cursor = conn.cursor()
cursor.execute("SELECT * FROM users")Specs
| Property | Value |
|---|---|
| Engine | PostgreSQL 17 |
| Image | postgres:17 |
| Port | 5432 |
| Volume | /var/lib/postgresql/data |
| Default Memory | 512Mi |
| Default vCPU | 0.5 |