summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases/postgres.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-04-03 16:06:06 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-04-03 16:06:06 +0000
commit030ef1f0ef37ccaebde06e58f22cd0de5a74c5d0 (patch)
tree2f596ed664bb60c7154c61add363d5532bb0782f /lib/sqlalchemy/databases/postgres.py
parentc416dad6c652262bafbb137e6412054481db8e2f (diff)
downloadsqlalchemy-030ef1f0ef37ccaebde06e58f22cd0de5a74c5d0.tar.gz
for #516, moved the "disconnect check" step out of pool and back into base.py. dialects have
is_disconnect() method now. simpler design which also puts control of the ultimate "execute" call back into the hands of the dialects.
Diffstat (limited to 'lib/sqlalchemy/databases/postgres.py')
-rw-r--r--lib/sqlalchemy/databases/postgres.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py
index a26ef76b6..6facde936 100644
--- a/lib/sqlalchemy/databases/postgres.py
+++ b/lib/sqlalchemy/databases/postgres.py
@@ -338,18 +338,16 @@ class PGDialect(ansisql.ANSIDialect):
cursor = connection.execute('''SELECT relname FROM pg_class WHERE relkind = 'S' AND relnamespace IN ( SELECT oid FROM pg_namespace WHERE nspname NOT LIKE 'pg_%%' AND nspname != 'information_schema' AND relname = %(seqname)s);''', {'seqname': sequence_name})
return bool(not not cursor.rowcount)
- def get_disconnect_checker(self):
- def disconnect_checker(e):
- if isinstance(e, self.dbapi.OperationalError):
- return 'closed the connection' in str(e) or 'connection not open' in str(e)
- elif isinstance(e, self.dbapi.InterfaceError):
- return 'connection already closed' in str(e)
- elif isinstance(e, self.dbapi.ProgrammingError):
- # yes, it really says "losed", not "closed"
- return "losed the connection unexpectedly" in str(e)
- else:
- return False
- return disconnect_checker
+ def is_disconnect(self, e):
+ if isinstance(e, self.dbapi.OperationalError):
+ return 'closed the connection' in str(e) or 'connection not open' in str(e)
+ elif isinstance(e, self.dbapi.InterfaceError):
+ return 'connection already closed' in str(e)
+ elif isinstance(e, self.dbapi.ProgrammingError):
+ # yes, it really says "losed", not "closed"
+ return "losed the connection unexpectedly" in str(e)
+ else:
+ return False
def reflecttable(self, connection, table):
if self.version == 2: