diff options
-rw-r--r-- | pgcli/main.py | 9 | ||||
-rw-r--r-- | pgcli/pgexecute.py | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/pgcli/main.py b/pgcli/main.py index d7853e47..adf42283 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -398,11 +398,12 @@ class PGCli(object): dsn='', **kwargs): # Connect to the database. - if not user: - user = getuser() + if not dsn: + if not user: + user = getuser() - if not database: - database = user + if not database: + database = user # If password prompt is not forced but no password is provided, try # getting it from environment variable. diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py index 8c3bfa82..6d94ccc6 100644 --- a/pgcli/pgexecute.py +++ b/pgcli/pgexecute.py @@ -233,7 +233,7 @@ class PGExecute(object): } new_params.update(kwargs) conn_params.update({ - k: unicode2utf8(v) for k, v in new_params.items() if v is not None + k: unicode2utf8(v) for k, v in new_params.items() if v }) if 'password' in conn_params and 'dsn' in conn_params: |