diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-04-02 22:03:06 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-04-02 22:03:06 +0000 |
commit | c416dad6c652262bafbb137e6412054481db8e2f (patch) | |
tree | 08d1b606fbe657011dd014ab4cd7d68165f7f063 /lib/sqlalchemy/databases/postgres.py | |
parent | cdceb3c3714af707bfe3ede10af6536eaf529ca8 (diff) | |
download | sqlalchemy-c416dad6c652262bafbb137e6412054481db8e2f.tar.gz |
- merged the patch from #516 + fixes
- improves the framework for auto-invalidation of connections that have
lost their underlying database - the error catching/invalidate
step is totally moved to the connection pool.
- added better condition checking for do_rollback() and do_commit() including
SQLError excepetion wrapping
Diffstat (limited to 'lib/sqlalchemy/databases/postgres.py')
-rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 2943d163e..a26ef76b6 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -338,6 +338,19 @@ 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 reflecttable(self, connection, table): if self.version == 2: ischema_names = pg2_ischema_names |