summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Trier <mtrier@gmail.com>2009-01-11 19:15:30 +0000
committerMichael Trier <mtrier@gmail.com>2009-01-11 19:15:30 +0000
commit9a3b662ec1a0fc5f531d96ef90434ce1f321334e (patch)
treea9b3cb10a178e7034af114b2080efbbee5869605
parent7b3b9f559a0c0a5a1e3bd3df37696037607af3fc (diff)
downloadsqlalchemy-9a3b662ec1a0fc5f531d96ef90434ce1f321334e.tar.gz
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.
-rw-r--r--CHANGES4
-rw-r--r--lib/sqlalchemy/databases/mssql.py9
2 files changed, 11 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 7dbd89333..bbaa5b33b 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 242fc5efb..a3d80c678 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,