python - Psycopg2 peer authentication for user postgress -
i seem have correctly installed postgresql 9.5.5. , psycopg2 on ubuntu 16.04, , can log in via:
sudo -u postgres psql if issue \conninfo, following:
you connected database "postgres" user "postgres" via socket in "/var/run/postgresql" @ port "5432". surely should able connect via psycopg2 in same fashion shown here, script:
#!/usr/bin/python import psycopg2 conn = psycopg2.connect("dbname=postgres user=postgres") conn.close() gives me:
psycopg2.operationalerror: fatal: peer authentication failed user "postgres" i want postgresql personal usage, don't want enable tcp authentication.
how correctly use peer authentication user "postgress" in psycopg2?
peer authentication works comparing postgres username in connection string name of linux user running script.
try running python script sudo -u postgres.
Comments
Post a Comment