Python psycopg2 timeout Python psycopg2 timeout python python

Python psycopg2 timeout


When using the keyword arguments syntax to the connect function it is possible to use any of the libpd supported connection parameters. Among those there is connect_timeout in seconds:

db = psycopg2.connect (    host=dhost, database=ddatabase,    user=duser, password=dpassword,    connect_timeout=3)

http://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-PARAMKEYWORDS

http://initd.org/psycopg/docs/module.html

A connection time out raises an OperationalError exception.