diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-09-21 17:43:22 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-09-21 17:43:22 -0400 |
| commit | 7e815c67a9b90774fbb9fa1865a7d79113ef3612 (patch) | |
| tree | 6a468fec4e3b619610daf16d920106088581b23a /lib | |
| parent | 434efdd2d973b7d72963f52741a6d78bb46cf7b8 (diff) | |
| download | sqlalchemy-7e815c67a9b90774fbb9fa1865a7d79113ef3612.tar.gz | |
finished fixes for mxodbc; need to use at least version 3.2.1
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/connectors/mxodbc.py | 19 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/mssql/mxodbc.py | 18 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/mssql/pyodbc.py | 5 |
3 files changed, 20 insertions, 22 deletions
diff --git a/lib/sqlalchemy/connectors/mxodbc.py b/lib/sqlalchemy/connectors/mxodbc.py index 69a8677e4..d74e9639b 100644 --- a/lib/sqlalchemy/connectors/mxodbc.py +++ b/lib/sqlalchemy/connectors/mxodbc.py @@ -134,23 +134,14 @@ class MxODBCConnector(Connector): if context: native_odbc_execute = context.execution_options.\ get('native_odbc_execute', 'auto') - if native_odbc_execute is True: - # user specified native_odbc_execute=True - return False - elif native_odbc_execute is False: - # user specified native_odbc_execute=False - return True - elif context.is_crud: - # statement is UPDATE, DELETE, INSERT - return False - else: - # all other statements - return True + # default to direct=True in all cases, is more generally + # compatible especially with SQL Server + return False if native_odbc_execute is True else True else: return True - #def do_executemany(self, cursor, statement, parameters, context=None): - # cursor.executemany(statement, parameters, direct=self._get_direct(context)) + def do_executemany(self, cursor, statement, parameters, context=None): + cursor.executemany(statement, parameters, direct=self._get_direct(context)) def do_execute(self, cursor, statement, parameters, context=None): cursor.execute(statement, parameters, direct=self._get_direct(context)) diff --git a/lib/sqlalchemy/dialects/mssql/mxodbc.py b/lib/sqlalchemy/dialects/mssql/mxodbc.py index 0044b5f4f..4e0af2d39 100644 --- a/lib/sqlalchemy/dialects/mssql/mxodbc.py +++ b/lib/sqlalchemy/dialects/mssql/mxodbc.py @@ -54,12 +54,15 @@ of ``False`` will unconditionally use string-escaped parameters. from ... import types as sqltypes from ...connectors.mxodbc import MxODBCConnector -from .pyodbc import MSExecutionContext_pyodbc +from .pyodbc import MSExecutionContext_pyodbc, _MSNumeric_pyodbc from .base import (MSDialect, MSSQLStrictCompiler, _MSDateTime, _MSDate, _MSTime) +class _MSNumeric_mxodbc(_MSNumeric_pyodbc): + """Include pyodbc's numeric processor. + """ class _MSDate_mxodbc(_MSDate): def bind_processor(self, dialect): @@ -91,12 +94,17 @@ class MSExecutionContext_mxodbc(MSExecutionContext_pyodbc): class MSDialect_mxodbc(MxODBCConnector, MSDialect): - # TODO: may want to use this only if FreeTDS is not in use, - # since FreeTDS doesn't seem to use native binds. - statement_compiler = MSSQLStrictCompiler + # this is only needed if "native ODBC" mode is used, + # which is now disabled by default. + #statement_compiler = MSSQLStrictCompiler + execution_ctx_cls = MSExecutionContext_mxodbc + + # flag used by _MSNumeric_mxodbc + _need_decimal_fix = True + colspecs = { - #sqltypes.Numeric : _MSNumeric, + sqltypes.Numeric : _MSNumeric_mxodbc, sqltypes.DateTime : _MSDateTime, sqltypes.Date : _MSDate_mxodbc, sqltypes.Time : _MSTime_mxodbc, diff --git a/lib/sqlalchemy/dialects/mssql/pyodbc.py b/lib/sqlalchemy/dialects/mssql/pyodbc.py index 83bf7ee6b..10149689a 100644 --- a/lib/sqlalchemy/dialects/mssql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mssql/pyodbc.py @@ -119,9 +119,8 @@ from ...util.compat import decimal class _MSNumeric_pyodbc(sqltypes.Numeric): """Turns Decimals with adjusted() < 0 or > 7 into strings. - This is the only method that is proven to work with Pyodbc+MSSQL - without crashing (floats can be used but seem to cause sporadic - crashes). + The routines here are needed for older pyodbc versions + as well as current mxODBC versions. """ |
