Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2016
    Posts
    2

    Unanswered: PostgreSQL connection error in python using Psycopg2

    Hello,

    I have following:

    Python 2.7.10
    Psycopg2
    PostgreSQL 9.4

    Trying to run a script to connect with PostgreSQL database using library Psycopg2 in my python script. I am having authentication issues with Postgres when i run the script. I made changes to pg_hba.conf and changed following lines to use TRUST (which is not the intended way to connect, as its insecure)

    # "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

    I want to connect to postgresql from my python script using psycopg2.connect but if i change METHOD to anything apart from TRUST, script fails with error:

    Traceback (most recent call last):
    File "parsejson.py", line 7, in <module>
    conn = psycopg2.connect("dbname='postgres' user='postgres' host='localhost' password='xxx'")
    File "/usr/local/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
    psycopg2.OperationalError: FATAL: password authentication failed for user "postgres"


    Please help !!

  2. #2
    Join Date
    Sep 2016
    Posts
    2

    PostgreQL connection error in python script using Psycopg2

    Hello,

    I have following:

    Python 2.7.10
    Psycopg2
    PostgreSQL 9.4

    Trying to run a script to connect with PostgreSQL database using library Psycopg2 in my python script. I am having authentication issues with Postgres when i run the script. I made changes to pg_hba.conf and changed following lines to use TRUST (which is not the intended way to connect, as its insecure)

    # "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

    I want to connect to postgresql from my python script using psycopg2.connect but if i change METHOD to anything apart from TRUST, script fails with error:

    Traceback (most recent call last):
    File "parsejson.py", line 7, in <module>
    conn = psycopg2.connect("dbname='postgres' user='postgres' host='localhost' password='xxx'")
    File "/usr/local/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
    psycopg2.OperationalError: FATAL: password authentication failed for user "postgres"


    Please help !!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •