Connecting to your database

UnitAutogen connects using the standard PostgreSQL environment variables. Set them once, then run any command:

set PGHOST=127.0.0.1
set PGPORT=5432
set PGUSER=postgres
set PGPASSWORD=********
set PGDATABASE=mydb

You can also supply a full connection string in UNITAUTOGEN_DSN instead of the separate variables, which is handy when switching between databases:

set UNITAUTOGEN_DSN=postgresql://postgres:********@127.0.0.1:5432/mydb

Setting variables depends on your shell

The examples above use the Windows Command Prompt (set VAR=value). The same variables on other shells:

  • Windows Command Prompt. set UNITAUTOGEN_DSN=postgresql://user:pass@host:5432/mydb
  • Windows PowerShell. $env:UNITAUTOGEN_DSN="postgresql://user:pass@host:5432/mydb"
  • Linux and macOS (bash, zsh). export UNITAUTOGEN_DSN=postgresql://user:pass@host:5432/mydb

Use whichever matches the terminal you run unitautogen from. The variable names and values are identical across all three.

Point the connection at a disposable copy of your database, never production. UnitAutogen probes each routine by seeding rows and running real statements, each rolled back, but the statements do run.