Add PGURI env var for passing connection string to psql in Docker - Mailing list pgsql-hackers

From Michael Leonhard
Subject Add PGURI env var for passing connection string to psql in Docker
Date
Msg-id CAHnQ7HPieKJEfHfFzf+PavQ_EA9Z3gxQ4RWNSKiOSACjgN+6-A@mail.gmail.com
Whole thread Raw
Responses Re: Add PGURI env var for passing connection string to psql in Docker
List pgsql-hackers
Hi PostgreSQL Hackers,
Please forgive me if this is not the preferred place to suggest a new
feature.  I found that a lot of items in the psql TODO list [1] were
posted to this email list.

I need to pass a connection string to psql inside Docker [2].  I can
pass it as a process argument, but this exposes the password to other
processes on my machine:
$ docker run --rm -i -t postgres:11 psql "$(cat db_uri)"

The alternative is to parse the URI, remove the password, and provide
the password via environment variable.  It's ugly:

$ PGPASSWORD=$(cat db_uri |grep -oE ':[a-zA-Z0-9]*@' |tr -d :@ ) \
docker run --rm -i -t postgres:11 \
psql "$(cat db_uri |sed 's/:[:alnum:]*@/@/')"

I would prefer to do this:
$ PGURI="$(cat db_uri)" docker run --rm -i -t postgres:11 -e PGURI psql
How about adding PGURI to the list of supported environment variables [3]?

Sincerely,
Michael

[1] https://wiki.postgresql.org/wiki/Todo#psql
[2] https://hub.docker.com/_/postgres
[3] https://www.postgresql.org/docs/devel/app-psql.html#APP-PSQL-ENVIRONMENT



pgsql-hackers by date:

Previous
From: Soumyadeep Chakraborty
Date:
Subject: Re: WIP: expression evaluation improvements
Next
From: Andres Freund
Date:
Subject: Re: [HACKERS] Moving relation extension locks out of heavyweightlock manager