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 DATABASE_URL instead of the separate variables. Many platforms and Supabase setups already set it, and UnitAutogen uses it with no extra step:
set DATABASE_URL=postgresql://postgres:********@127.0.0.1:5432/mydb
To point UnitAutogen at a different database from the rest of your tools, set UNITAUTOGEN_DSN. It wins over DATABASE_URL:
set UNITAUTOGEN_DSN=postgresql://postgres:********@127.0.0.1:5432/mydb_test
UNITAUTOGEN_DSN comes first.DATABASE_URL is used when neither of those is set.PG variables are used only when neither connection string is set.DATABASE_URL before you run. It often points at an application's real database. Point UnitAutogen at a test or disposable copy, or set UNITAUTOGEN_DSN to override it.The examples above use the Windows Command Prompt (set VAR=value). The same variables on other shells:
set DATABASE_URL=postgresql://user:pass@host:5432/mydb$env:DATABASE_URL="postgresql://user:pass@host:5432/mydb"export DATABASE_URL=postgresql://user:pass@host:5432/mydbUse whichever matches the terminal you run unitautogen from. The variable names and values are identical across all three.
unitautogen stops before generating anything, with exit code 4. The message names the variable it used, never its value, since that holds the password.
CANNOT CONNECT to PostgreSQL using the connection string in DATABASE_URL: <reason>
-> set the connection via environment variables: PGHOST, PGPORT, PGDATABASE, PGUSER, PGPASSWORD
(or a single connection string in UNITAUTOGEN_DSN or DATABASE_URL, e.g. postgresql://user:password@host:5432/dbname)
Nothing was generated.
With no connection string set, the first line names the host, port, database and user instead. A connection attempt gives up after 10 seconds.
In a Supabase project you can skip this page. Supabase mode finds the local database for you.