You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: support standard postgres env vars for db connection (#674)
Support `DATABASE_URL`, `PGHOST`, `PGPORT`, `PGUSER`, `PGPASSWORD`,
`PGDATABASE` env vars for configuring the database connection with
highest priority.
we use bpaf(env()) for the cli, and support loading the db config
from_env for the lsp.
These env var names follow the standard [libpq environment
variables](https://www.postgresql.org/docs/current/libpq-envars.html)
(`PG*`) and the widely adopted `DATABASE_URL` convention used by tools
like `sqlx`, `diesel`, `prisma`, and `dotenv`.
### Example
```sh
DATABASE_URL=postgres://user:pass@localhost:5432/mydb postgres-language-server check file.sql
# or individual vars
PGHOST=localhost PGPORT=5432 PGUSER=user PGPASSWORD=pass PGDATABASE=mydb postgres-language-server check file.sql
```
### Precedence (highest to lowest)
1. Environment variables
2. CLI args / LSP client settings
3. Config file
4. Defaults
Closes#302
0 commit comments