psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
+class ConnectionError():
+ pass
+
class connect(object):
def __init__(self, dsn):
options = dsn.copy()
self.driver = psycopg2.connect(**options)
break
except psycopg2.OperationalError, e:
+ if e.message.startswith('could not connect to server: Connection refused\n'):
+ raise ConnectionError()
if attempt == 2:
raise
attempt = attempt + 1