dbcli / pgcli

Postgres CLI with autocompletion and syntax highlighting
http://pgcli.com
BSD 3-Clause "New" or "Revised" License
11.99k stars 551 forks source link

Using standard postgresql "service=[service-name]" to connect does not work #1205

Open levihb opened 4 years ago

levihb commented 4 years ago

Description

Using the standard services syntax to connect, e.g.

psql service=myservice

Does not appear to work with pgcli? I noticed that this was supposedly fixed with #1035 and #1051 but it still doesn't work for me? This is rather frustrating as I use services a lot. I've tried both:

pgcli service=myservice

and the following (as this normally works on 3rd party interactions even if the above doesn't):

pgcli "postgresql:///?service=cf"

Instead I just get asked for a password?

Your environment

pip freeze:

acme==1.7.0
alabaster==0.7.12
anytree==2.8.0
appdirs==1.4.4
arandr==0.1.10
asciinema==2.0.2
asgiref==3.2.10
asn1crypto==1.4.0
astroid==2.4.2
attrs==19.3.0
awscli==1.18.120
Babel==2.8.0
backcall==0.2.0
Beaker==1.11.0
bitwarden-keyring==0.3.0
bleach==3.1.5
botocore==1.17.43
btrfsutil==1.2.0
CacheControl==0.12.6
ceph-volume==1.0.0
cephfs==2.0.0
cephfs-shell==0.0.1
certbot==1.7.0
cffi==1.14.2
chardet==3.0.4
clang==6.0.0.2
cli-helpers==2.1.0
click==7.1.2
colorama==0.4.3
ConfigArgParse==1.2.3
configobj==5.0.6
contextlib2==0.6.0.post1
cPython==0.0.5
cryptography==3.0
decorator==4.4.2
defusedxml==0.6.0
distlib==0.3.1
distro==1.5.0
Django==3.1
docutils==0.16
entrypoints==0.3
enum-compat==0.0.3
fido2==0.8.1
flake8==3.7.9
future==0.18.2
gmplot==1.2.0
html5lib==1.1
humanize==2.6.0
i3ipc==2.1.1
idna==2.10
imagesize==1.2.0
importlib-metadata==1.6.1
ipykernel==5.3.4
ipython==7.17.0
ipython-genutils==0.1.0
ipywidgets==7.5.1
isort==4.3.21
jedi==0.17.0
jeepney==0.4.3
Jinja2==2.11.2
jmespath==0.10.0
josepy==1.4.0
json5==0.9.5
jsonschema==3.2.0
jupyter-client==6.1.3
jupyter-console==6.1.0
jupyter-core==4.6.3
jupyterlab==2.2.4
jupyterlab-server==1.2.0
keyring==21.2.0
lazy-object-proxy==1.4.3
lensfun==0.3.95
lit==0.10.1.dev0
lockfile==0.12.2
louis==3.14.0
lxml==4.5.2
Mako==1.1.3
mallard-ducktype==1.0.2
Markdown==3.2.2
MarkupSafe==1.1.1
mccabe==0.6.1
meson==0.55.1
Mimeo==2019.7.6.0.8.17
mistune==0.8.4
mock==3.0.5
more-itertools==8.4.0
msgpack==1.0.0
nbconvert==5.6.1
nbformat==5.0.6
notebook==6.1.1
ordered-set==4.0.2
packaging==20.4
pandocfilters==1.4.2
parsedatetime==2.6
parso==0.8.0
pbr==5.4.5
pdftotext==2.1.4
pep517==0.8.2
pexpect==4.8.0
pgcli==3.0.0
pgspecial==1.11.10
pickleshare==0.7.5
ply==3.11
progress==1.5
prometheus-client==0.8.0
prompt-toolkit==3.0.6
psycopg2==2.8.5
ptyprocess==0.6.0
pyasn1==0.4.8
pycairo==1.19.1
pycodestyle==2.5.0
pycparser==2.20
pyflakes==2.1.1
Pygments==2.6.1
PyGObject==3.36.1
pymongo==3.10.1
pyOpenSSL==19.1.0
pyparsing==2.4.7
pyPEG2==2.15.2
PyQt5==5.15.0
PyQt5-sip==12.8.0
PyQtWebEngine==5.15.0
pyRFC3339==1.1
pyrsistent==0.16.0
pyscard==1.9.9
python-dateutil==2.8.1
python-xlib==0.26
pytoml==0.1.21
pytz==2020.1
pyudev==0.22.0.dev20200622
pyusb==1.0.2
pyxdg==0.26
PyYAML==5.3.1
pyzmq==19.0.1
qutebrowser==1.13.1
rados==2.0.0
ranger-fm==1.9.2
rbd==2.0.0
requests==2.24.0
requests-toolbelt==0.9.1
resolvelib==0.4.0
retrying==1.3.3
rgw==2.0.0
rsa==4.6
s3transfer==0.3.3
SecretStorage==3.1.2
Send2Trash==1.5.0
setproctitle==1.1.10
six==1.15.0
snowballstemmer==2.0.0
solaar==1.0.3
Sphinx==3.2.1
sphinx-rtd-theme==0.5.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4
sqlparse==0.3.1
tabulate==0.8.7
team==1.0
terminado==0.8.3
terminaltables==3.1.0
testpath==0.4.4
toml==0.10.1
tornado==6.0.4
traitlets==4.3.3
urllib3==1.25.10
wcwidth==0.2.5
webencodings==0.5.1
widgetsnbextension==3.5.1
wrapt==1.12.1
youtube-dl==2020.7.28
yubikey-manager==3.1.1
zipp==3.1.0
zope.component==4.6.2
zope.deferredimport==4.3.1
zope.deprecation==4.4.0
zope.event==4.4
zope.hookable==5.0.1
zope.interface==5.1.0
zope.proxy==4.3.5
levihb commented 4 years ago

Oh ok I didn't realize it was trying to get the password from the keyring.

I think the keyring only needs to be checked if there's no valid password in .pgpass though. Because at the moment the search order is:

  1. Command line
  2. PGPASSWORD environment variable
  3. Keyring
  4. .pgpass
  5. Asking

Surely it should follow the default logic of psql and check .pgpass before the keyring? Because otherwise you have to turn the keyring off.