Skip to content

Support libpq standard environment variables #3100

Description

@PadenZach

Feature description

I'd like graphile/pgl to support standard postgres environmental variables as defined by libpq. While all of them would be awesome, the high priority ones I'd consider are:

Highest Priority

These would allow for immediate, easy dev integration.

  • PGHOST
  • PGPASSWORD
  • PGPORT
  • PGDATBASE
  • PGUSER
  • PGSSLMODE
  • PGSERVICE (and ergo pg service files)

These would cover most basic interop patterns for devs.

Impactful

These would be awesome, but not as strictly required for a use perspective.

  • PGOPTIONS
  • PGAPPNAME
  • PGSSLCERT
  • PGPASSFILE

Many of the other non-deprecated ones would also be great.

Motivating example

Just started using this as a brief example, curious how it works.

I went to the docs and immediately ran a:

npx pgl -P pgl/amber -e expecting it to "just work" with my current env var connection. It didnt. I need either go and generate a plain text connection as you want, manually type in all the various cli options to pgl, or write pgl's custom config format.

This feature makes your tool more adoptable by postgres users & it's ecosystem

eg:

# check the db
psql -c "SELECT 1"
# what schema am I in?
psql -c "SHOW search_path"
# awesome, run a migration
./migrate.sh (many db utils support lib pq)
# run our other app server
python some-psycopg-or-asyncpg-app.py
# kill that then run *pgql* 8)

I've seen some trace references to this, but cant find a clear list and after trying for several minutes nothings seems to get it working using _just_ pg env vars.

### Breaking changes

certain pgl / postgraphile command may start a server where as before it wouldnt.

### Supporting development

May be interested if I end up using graphile more in the future, still evaluating

- [ ] am interested in building this feature myself
- [ ] am interested in collaborating on building this feature
- [ ] am willing to help testing this feature before it's released
- [ ] am willing to write a test-driven test suite for this feature (before it exists)
- [ ] am a [Graphile sponsor](https://www.graphile.org/sponsor/) ❤️
- [ ] have an active [support or consultancy contract](https://www.graphile.org/support/) with Graphile

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions