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