question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OperationalError on all queries

See original GitHub issue

Description

I get the following error when I start pgcli:

Exception in thread completion_refresh:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 812, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 765, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/site-packages/pgcli/completion_refresher.py", line 60, in _bg_refresh
    **e.extra_args)
  File "/usr/lib/python2.7/site-packages/pgcli/pgexecute.py", line 173, in __init__
    self.connect()
  File "/usr/lib/python2.7/site-packages/pgcli/pgexecute.py", line 198, in connect
    **kwargs)
  File "/usr/lib64/python2.7/site-packages/psycopg2/__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
OperationalError: could not translate host name " /tmp" to address: Name or service not known

I can execute psql commands fine, but all queries just return the above error, as well.

Your environment

Centos 7 Python 2.7.5 Installed pgcli via pip Postgres version 10.3

I’ve tried installing pgcli on an empty virtualenv, but get the same results.

pip freeze:

backports.csv==1.0.5
backports.ssl-match-hostname==3.4.0.2
chardet==2.2.1
cli-helpers==1.0.1
click==6.7
configobj==5.0.6
decorator==3.4.0
fail2ban==0.9.7
humanize==0.5.1
iniparse==0.4
iotop==0.6
kitchen==1.1.1
langtable==0.0.31
perf==0.1
pgcli==1.9.0
pgspecial==1.10.0
prompt-toolkit==1.0.15
psycopg2-binary==2.7.4
pycurl==7.19.0
Pygments==2.2.0
pygobject==3.22.0
pygpgme==0.3
pyliblzma==0.5.3
python-augeas==0.5.0
python-dmidecode==3.10.13
python-linux-procfs==0.4.9
pyudev==0.15
pyxattr==0.5.1
schedutils==0.4
setproctitle==1.1.10
six==1.9.0
slip==0.4.0
slip.dbus==0.4.0
sqlparse==0.2.4
tabulate==0.8.2
terminaltables==3.1.0
urlgrabber==3.10
virtualenv==15.2.0
wcwidth==0.1.7
yum-langpacks==0.4.2
yum-metadata-parser==1.1.4

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
joaodlfcommented, Jul 24, 2018

Sure!

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust

# Allow external connections with a password
host    all             all             0.0.0.0/0               md5
host    all             all             ::/0                    md5

This is from the same machine as expressed in my initial report:

PostgreSQL 10.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit

pgcli will only work as expected with the following command: pgcli -U postgres -h localhost

0reactions
trstringercommented, Sep 12, 2018

For what it’s worth, I’m running into the same problem and @joaodlf’s workaround is working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - SQL operational error while searching for a query in ...
This is a follow up from this question: SQL query, IMDB data : To find an actors who did more films with Yash...
Read more >
OperationalError: sorry, too many clients already - Django Forum
So, I tried running the query and immediately picking some PID's and ports to see if there were any active processes running with...
Read more >
sqlite3.OperationalError: no such table: playbooks #263 - GitHub
After running a playbook which does something, it works better indeed. However I think the tool could be enhanced to detect an empty...
Read more >
SQL Part 2: Working with Databases through Python
Identifying SQL-Specific Errors: sqlite3.OperationalError ... This exception is generated by SQLite3, usually when our query syntax is incorrect. When you receive ...
Read more >
MySQLdb._exceptions.OperationalError: (2006, '') when ...
So when I get a MySQLdb._exceptions.OperationalError: (2006, '') when closing a SQL query. Is it because of the connection? mysql- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found