summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/pg8000.py
diff options
context:
space:
mode:
authorTony Locke <tlocke@tlocke.org.uk>2014-08-24 15:15:17 +0100
committerTony Locke <tlocke@tlocke.org.uk>2014-12-16 21:03:04 +0000
commitc93706fa3319663234e3ab886b65f055bf9ed5da (patch)
treeda4c8bd1bd8176adf0ddacec631b222f5eb17653 /lib/sqlalchemy/dialects/postgresql/pg8000.py
parent8038cfa0771ff860f48967a6800477ce8a508d65 (diff)
downloadsqlalchemy-c93706fa3319663234e3ab886b65f055bf9ed5da.tar.gz
Make pg8000 version detection more robust
pg8000 uses Versioneer, which means that development versions have version strings that don't fit into the dotted triple number format. Released versions will always fit the triple format though.
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/pg8000.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/pg8000.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py
index a76787016..17d83fa61 100644
--- a/lib/sqlalchemy/dialects/postgresql/pg8000.py
+++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py
@@ -71,6 +71,7 @@ from ... import types as sqltypes
from .base import (
PGDialect, PGCompiler, PGIdentifierPreparer, PGExecutionContext,
_DECIMAL_TYPES, _FLOAT_TYPES, _INT_TYPES)
+import re
class _PGNumeric(sqltypes.Numeric):
@@ -151,15 +152,19 @@ class PGDialect_pg8000(PGDialect):
self.client_encoding = client_encoding
def initialize(self, connection):
- if self.dbapi and hasattr(self.dbapi, '__version__'):
- self._dbapi_version = tuple([
- int(x) for x in
- self.dbapi.__version__.split(".")])
- else:
- self._dbapi_version = (99, 99, 99)
self.supports_sane_multi_rowcount = self._dbapi_version >= (1, 9, 14)
super(PGDialect_pg8000, self).initialize(connection)
+ @util.memoized_property
+ def _dbapi_version(self):
+ if self.dbapi and hasattr(self.dbapi, '__version__'):
+ return tuple(
+ [
+ int(x) for x in re.findall(
+ r'(\d+)(?:[-\.]?|$)', self.dbapi.__version__)])
+ else:
+ return (99, 99, 99)
+
@classmethod
def dbapi(cls):
return __import__('pg8000')