diff options
author | Ramiro Morales <ramiro@rmorales.net> | 2015-04-05 19:14:54 -0300 |
---|---|---|
committer | Ramiro Morales <ramiro@rmorales.net> | 2015-04-05 19:14:54 -0300 |
commit | c75c6732b115c136043eb5c74d4388abe865d2a3 (patch) | |
tree | f25630722cd883e344e350812fee27c047e598b5 | |
parent | 112a11069d4452328e2677d962fc4284392ee5a8 (diff) | |
download | sqlalchemy-pr/166.tar.gz |
- pymssql has PEP249 Binary contructor since 2.1.1pr/166
See https://github.com/pymssql/pymssql/commit/e7fb15dd29090e1f1bb570842b53aea1ec32d8f0
-rw-r--r-- | lib/sqlalchemy/dialects/mssql/pymssql.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/pymssql.py b/lib/sqlalchemy/dialects/mssql/pymssql.py index 2214d18d1..324b3770c 100644 --- a/lib/sqlalchemy/dialects/mssql/pymssql.py +++ b/lib/sqlalchemy/dialects/mssql/pymssql.py @@ -46,11 +46,12 @@ class MSDialect_pymssql(MSDialect): @classmethod def dbapi(cls): module = __import__('pymssql') - # pymmsql doesn't have a Binary method. we use string - # TODO: monkeypatching here is less than ideal - module.Binary = lambda x: x if hasattr(x, 'decode') else str(x) - + # pymmsql < 2.1.1 doesn't have a Binary method. we use string client_ver = tuple(int(x) for x in module.__version__.split(".")) + if client_ver < (2, 1, 1): + # TODO: monkeypatching here is less than ideal + module.Binary = lambda x: x if hasattr(x, 'decode') else str(x) + if client_ver < (1, ): util.warn("The pymssql dialect expects at least " "the 1.0 series of the pymssql DBAPI.") |