Can't connect the postgreSQL with psycopg2

后端 未结 6 539
无人及你
无人及你 2020-11-30 04:08

It\'s the first time that I can\'t find the answer about some tech problems Here\'s my problems:

>> conn=psycopg2.connect(database=\"mydb\", user=\"pos         


        
6条回答
  •  一个人的身影
    2020-11-30 04:11

    Your libpq, which is used by psycopg2 expects Postgres socket to be in /var/run/postgresql/ but when you install Postgres from source it is by default it in /tmp/.

    Check if there is a file /tmp/.s.PGSQL.5432 instead of /var/run/postgresql/.s.PGSQL.5432. Try:

    conn=psycopg2.connect(
      database="mydb",
      user="postgres",
      host="/tmp/",
      password="123"
    )
    

提交回复
热议问题