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.