Connection String Builder

Build once, get every format

libpq URI
postgresql://postgres@localhost/mydb
psql CLI
psql "postgresql://postgres@localhost/mydb"
.env / DATABASE_URL
DATABASE_URL="postgresql://postgres@localhost/mydb"
JDBC
jdbc:postgresql://localhost/mydb?user=postgres
SQLAlchemy (Python)
engine = create_engine("postgresql+psycopg2://postgres@localhost/mydb")
psycopg2 (Python — legacy)
conn = psycopg2.connect(
  host="localhost",
  port=5432,
  dbname="mydb",
  user="postgres"
)
psycopg3 (Python — current)
conn = psycopg.connect("postgresql://postgres@localhost/mydb")
node-postgres (JS/TS)
const client = new Client({
  host: "localhost",
  port: 5432,
  database: "mydb",
  user: "postgres"
});
Go (pgx)
conn, err := pgx.Connect(context.Background(), "postgresql://postgres@localhost/mydb")