summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-02-09 15:06:32 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-02-09 15:06:32 -0500
commit6f16b8db6f08cefd68cdf251292316497eb849b3 (patch)
treedd86ad7eb16671bfec3ea091f2b0cfd5b6e18893 /lib/sqlalchemy/dialects/postgresql
parentf473398f0170a00b0e760a7dba292087144c7e45 (diff)
downloadsqlalchemy-6f16b8db6f08cefd68cdf251292316497eb849b3.tar.gz
- add connection and cursor to is_disconnect(). We aren't using it yet,
but we'd like to. Most DBAPIs don't give us anything we can do with it. Some research was done on psycopg2 and it still seems like they give us no adequate method (tried connection.closed, cursor.closed, connection.status). mxodbc claims their .closed attribute will work (but I am skeptical). - remove beahvior in pool that auto-invalidated a connection when the cursor failed to create. That's not the pool's job. we need the conn for the error logic. Can't get any tests to fail, curious why that behavior was there, guess we'll find out (or not). - add support for psycopg2 version detection. even though we have no use for it yet... - adjust one of the reconnect tests to work with oracle's horrendously slow connect speed
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/pg8000.py2
-rw-r--r--lib/sqlalchemy/dialects/postgresql/psycopg2.py8
-rw-r--r--lib/sqlalchemy/dialects/postgresql/pypostgresql.py2
3 files changed, 9 insertions, 3 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py
index d3c2f1d50..c4f00eabe 100644
--- a/lib/sqlalchemy/dialects/postgresql/pg8000.py
+++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py
@@ -108,7 +108,7 @@ class PGDialect_pg8000(PGDialect):
opts.update(url.query)
return ([], opts)
- def is_disconnect(self, e):
+ def is_disconnect(self, e, connection, cursor):
return "connection is closed" in str(e)
dialect = PGDialect_pg8000
diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
index 50ea9d437..10d6e0269 100644
--- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py
+++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
@@ -227,6 +227,7 @@ class PGDialect_psycopg2(PGDialect):
execution_ctx_cls = PGExecutionContext_psycopg2
statement_compiler = PGCompiler_psycopg2
preparer = PGIdentifierPreparer_psycopg2
+ psycopg2_version = (0, 0)
colspecs = util.update_copy(
PGDialect.colspecs,
@@ -243,6 +244,11 @@ class PGDialect_psycopg2(PGDialect):
self.server_side_cursors = server_side_cursors
self.use_native_unicode = use_native_unicode
self.supports_unicode_binds = use_native_unicode
+ if self.dbapi and hasattr(self.dbapi, '__version__'):
+ m = re.match(r'(\d+)\.(\d+)\.(\d+)?',
+ self.dbapi.__version__)
+ if m:
+ self.psycopg2_version = tuple(map(int, m.group(1, 2, 3)))
@classmethod
def dbapi(cls):
@@ -295,7 +301,7 @@ class PGDialect_psycopg2(PGDialect):
opts.update(url.query)
return ([], opts)
- def is_disconnect(self, e):
+ def is_disconnect(self, e, connection, cursor):
if isinstance(e, self.dbapi.OperationalError):
# these error messages from libpq: interfaces/libpq/fe-misc.c.
# TODO: these are sent through gettext in libpq and we can't
diff --git a/lib/sqlalchemy/dialects/postgresql/pypostgresql.py b/lib/sqlalchemy/dialects/postgresql/pypostgresql.py
index dd22fcb33..a137a6240 100644
--- a/lib/sqlalchemy/dialects/postgresql/pypostgresql.py
+++ b/lib/sqlalchemy/dialects/postgresql/pypostgresql.py
@@ -67,7 +67,7 @@ class PGDialect_pypostgresql(PGDialect):
opts.update(url.query)
return ([], opts)
- def is_disconnect(self, e):
+ def is_disconnect(self, e, connection, cursor):
return "connection is closed" in str(e)
dialect = PGDialect_pypostgresql