Skip to main content

PostgreSQL

devstack add postgres

Options

FlagDefaultDescription
-p, --port5432Host port to expose
-u, --usernamepostgresDatabase username
-P, --passwordpostgresDatabase password
-d, --databasepostgresDefault database name
# Custom credentials
devstack add postgres --username myapp --password secret --database myapp_dev

Connection string

postgresql://postgres:postgres@localhost:5432/postgres

Connect interactively

devstack connect postgres

Opens psql inside the running container.

Application config examples

.env
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres
TypeScript (pg)
import { Pool } from 'pg';
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
Python (psycopg2)
import psycopg2
conn = psycopg2.connect("postgresql://postgres:postgres@localhost:5432/postgres")