from psycopg2.pool import PoolError
import psycopg2.extensions
+import warnings
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
@wraps(f)
def wrapper(self, *args, **kwargs):
if self.__closed:
- raise psycopg2.ProgrammingError('Unable to use the cursor after having closed it')
+ raise psycopg2.OperationalError('Unable to use the cursor after having closed it')
return f(self, *args, **kwargs)
return wrapper
def __nonzero__(self):
"""Check if connection is possible"""
try:
+ warnings.warn("You use an expensive function to test a connection.",
+ DeprecationWarning, stacklevel=1)
cr = self.cursor()
cr.close()
return True
- except:
+ except Exception:
return False