From: Michael Trier Date: Sun, 11 Jan 2009 19:15:30 +0000 (+0000) Subject: Modified the do_begin handling in mssql to use the Cursor not the Connection. X-Git-Tag: rel_0_5_1~33 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9a3b662ec1a0fc5f531d96ef90434ce1f321334e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Modified the do_begin handling in mssql to use the Cursor not the Connection. This corrects a problem where we were trying to call execute on the Connection object instead of against the cursor. This is supported on pyodbc but not in the DBAPI. Overrode the behavior in pymssql to not do special do_begin processing on that dialect. --- diff --git a/CHANGES b/CHANGES index 7dbd893333..bbaa5b33b7 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,10 @@ CHANGES - Added the missing keywords from MySQL 4.1 so they get escaped properly. +- mssql + - Modified the do_begin handling in mssql to use the Cursor not + the Connection so it is DBAPI compatible. + 0.5.0 ======== diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 242fc5efb5..a3d80c6786 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -1056,8 +1056,9 @@ class MSSQLDialect(default.DefaultDialect): return newobj def do_begin(self, connection): - connection.execute("SET IMPLICIT_TRANSACTIONS OFF") - connection.execute("BEGIN TRANSACTION") + cursor = connection.cursor() + cursor.execute("SET IMPLICIT_TRANSACTIONS OFF") + cursor.execute("BEGIN TRANSACTION") @base.connection_memoize(('dialect', 'default_schema_name')) def get_default_schema_name(self, connection): @@ -1304,6 +1305,9 @@ class MSSQLDialect_pymssql(MSSQLDialect): def is_disconnect(self, e): return isinstance(e, self.dbapi.DatabaseError) and "Error 10054" in str(e) + def do_begin(self, connection): + pass + class MSSQLDialect_pyodbc(MSSQLDialect): supports_sane_rowcount = False @@ -1430,6 +1434,7 @@ class MSSQLDialect_adodbapi(MSSQLDialect): def is_disconnect(self, e): return isinstance(e, self.dbapi.adodbapi.DatabaseError) and "'connection failure'" in str(e) + dialect_mapping = { 'pymssql': MSSQLDialect_pymssql, 'pyodbc': MSSQLDialect_pyodbc,