När du använder syntaxen för sökordsargument till connect funktionen är det möjligt att använda vilken som helst av libpd anslutningsparametrar som stöds. Bland dessa finns connect_timeout på sekunder:
db = psycopg2.connect (
host=dhost, database=ddatabase,
user=duser, password=dpassword,
connect_timeout=3
)
https://www.postgresql.org/docs /current/static/libpq-connect.html#LIBPQ-PARAMKEYWORDS
https://initd.org/psycopg/docs/module.html
En timeout för anslutning ger ett OperationalError
undantag.