Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to test pyhton-postgresql script in ubuntu 12.04.

The script is this:

    import psycopg2
    import sys


    con = None

    try:

            con = psycopg2.connect(database='mydb', user='myuser') 
            cur = con.cursor()
            cur.execute("SQL")
    con.commit()


   except psycopg2.DatabaseError, e:

   if con:
         con.rollback()

   print 'Error %s' % e    
   sys.exit(1)


 finally:

     if con:
          con.close()

and the error I get each time I run the script from the terminal (python myscript.py) is:

Error  could not connect server: No such file or directory 
Is the server running locally and accepting connection on unix domain socket "/tmp/.s.PGSQL.5432"?

I don't have any idea what this mean, and I have been looking around for a while now. All to no avail.

Any help would be appreciated.

share|improve this question
    
Can you provide the script, or atleast the lines you use to connect to the db? –  Salem Jul 18 '13 at 10:28
    
@Salem Thanks I have posted an extract from the script –  kplus Jul 18 '13 at 10:38
    
And PostgreSQL is installed and running? You can connect to it using psql or PgAdmin? –  Salem Jul 18 '13 at 10:42
    
let me give it a try. Thanks –  kplus Jul 18 '13 at 10:47
    
PostgreSQL is installed and it's running. Do I need to do any configuration before I can use psql or PgAdmin? –  kplus Jul 18 '13 at 10:50
show 6 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.