1
1
mirror of https://github.com/dbcli/pgcli.git synced 2024-10-06 18:27:29 +03:00

Added support for PGPASSWORD environment variable. Connect #220.

This commit is contained in:
Iryna Cherniavska 2015-06-22 19:23:35 -07:00
parent f7cfbaab16
commit f12f2937ed

View File

@ -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.