We are trying to access the database of odoo running on 104.154.90.232 through python. I have used psycopg2 to connect. My code is like this:

import psycopg2

import sys

import pprint

conn_string = "host='104.154.90.232' dbname='dbname' user='user' password='password'"

print "connecting to the database\n ->%s"%(conn_string)

conn = psycopg2.connect(conn_string)

cursor = conn.cursor()

cursor.execute("SELECT * FROM hr_employee")

records = cursor.fetchall()

pprint.pprint(records)



The error is:

Traceback (most recent call last):

File "test.py", line 6, in <module>

conn = psycopg2.connect(conn_string)

File "C:\Python27\lib\site-packages\psycopg2\__init__.py", line 130, in connect

conn = _connect(dsn, connection_factory=connection_factory, **kwasync)

psycopg2.OperationalError: could not connect to server: Connection timed out (0x0000274C/10060)

Is the server running on host "104.154.90.232" and accepting

TCP/IP connections on port 5432?

Can Someone help me in establishing the connection?