summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Francisco <xavier.n.francisco@gmail.com>2019-04-08 19:46:29 +0100
committerXavier Francisco <xavier.n.francisco@gmail.com>2019-04-08 19:46:29 +0100
commit49582ccb7c4ec98aa9736c02d300096952d065fe (patch)
treed39b3d21038f5eea91f7e0ec4e60d4a806373f8a
parent098a2cf976dff387e324db334cc5fbd17cbd1bc1 (diff)
Fix usage of pgservice
-rw-r--r--pgcli/main.py9
-rw-r--r--pgcli/pgexecute.py2
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: