Skip to content

PGPASSWORD env variable takes precedence over "password=...." in the DSN uri #1555

@ochaton

Description

@ochaton

Hello guys!

I'm using pgcli to connect to AWS RDS and constantly switching accounts. Currently I'm using pgcli 4.4.0. My flow looks like this (basically it's just simple shell one-command):

# for production:export PRODPGPASSWORD=$(aws rds generate-db-auth-token --hostname $PRODRDS --port 5432 --username $PRODUSER); pgcli "host=$PRODRDS port=5432 dbname=$DBNAME user=$PRODUSER password=$PRODPGPASSWORD"

# for development:export PGPASSWORD=$(aws rds generate-db-auth-token --hostname $DEVRDS --port 5432 --username $DEVUSER); pgcli "host=$DEVRDS port=5432 dbname=$DBNAME user=$DEVUSER password=$PGPASSWORD"

So, after thorough investigation, I caught that I need to unset $PGPASSWORD before connecting to my Database, so pgcli will use <password> from the DSN URI.
Is it an intentional design of the pgcli, or just a minor inconvenience?

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