diff options
author | Iryna Cherniavska <i.chernyavska@gmail.com> | 2015-06-22 19:23:35 -0700 |
---|---|---|
committer | Iryna Cherniavska <i.chernyavska@gmail.com> | 2015-06-22 19:23:35 -0700 |
commit | f12f2937ed3ba08c3558bf170006c97ceb7459df (patch) | |
tree | 3b6b7cadb7f084407ca8a23031198c5dfe070faa | |
parent | f7cfbaab1689b50640adb75476fa14800aaf9eae (diff) |
Added support for PGPASSWORD environment variable. Connect #220.
-rwxr-xr-x | pgcli/main.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/pgcli/main.py b/pgcli/main.py index 7252dc92..6a6899d0 100755 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -142,6 +142,11 @@ class PGCli(object): if not database: database = user + # If password prompt is not forced but no password is provided, try + # getting it from environment variable. + if not self.force_passwd_prompt and not passwd: + passwd = os.environ.get('PGPASSWORD', '') + # Prompt for a password immediately if requested via the -W flag. This # avoids wasting time trying to connect to the database and catching a # no-password exception. |