I can not use .pgpass file while connecting to postgresql db using python script((( My python script to connect is without password:
conn = psycopg2.connect("dbname='postgres' user='postgres' host='192.168.136.129'");
My .pgpass:
*:*:*:postgres:password
is located in /var/lib/postgresql - home directory for postgres user. However when I connect to db locally:
psql -U postgres
no password is asked. But for python error is raised:
root@debian:/python_codes/Junior/Level1/DB1/Generator_py# python connect_db.py
Unable to connect to db...
Traceback (most recent call last):
File "connect_db.py", line 34, in connectdb
conn = psycopg2.connect("dbname='postgres' user='postgres' host='192.168.136.129'");
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
OperationalError: fe_sendauth: no password supplied
.pgpassfile to the home directory of the UNIX user running the script on another server.