From: Brad Allen Date: Mon, 8 Mar 2010 21:57:18 +0000 (-0600) Subject: Temporary kludge to fix InterfaceError, in places where cursor.executedirect is neede... X-Git-Tag: rel_0_6beta2~65 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2fbf396ba0d478499f5fae8ee9c091879c2ce2a4;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Temporary kludge to fix InterfaceError, in places where cursor.executedirect is needed instead of cursor.execute. --- diff --git a/lib/sqlalchemy/connectors/mxodbc.py b/lib/sqlalchemy/connectors/mxodbc.py index 49c5a73293..fd1a69ace3 100644 --- a/lib/sqlalchemy/connectors/mxodbc.py +++ b/lib/sqlalchemy/connectors/mxodbc.py @@ -3,6 +3,7 @@ import sys import re from sqlalchemy.connectors import Connector +from mx.ODBC import InterfaceError class MxODBCConnector(Connector): driver='mxodbc' @@ -75,3 +76,17 @@ class MxODBCConnector(Connector): except ValueError: version.append(n) return tuple(version) + + def do_execute(self, cursor, statement, parameters, context=None): + """ Override the default do_execute for all dialects using mxODBC. + + This is needed because mxODBC expects a sequence of sequences + (usually a tuple of tuples) for the bind parameters, and + SQLAlchemy commonly sends a list containing a string, + which mxODBC interprets as a sequence and breaks out the + individual characters. + """ + try: + cursor.execute(statement, tuple(parameters)) + except InterfaceError: + cursor.executedirect(statement, tuple(parameters))