Commits

paj committed 5bdbd7f

automatically use_scope_identity if an appropriate version of PyODBC is installed

  • Participants
  • Parent commits b35a6fe
  • Branches rel_0_3

Comments (0)

Files changed (1)

File lib/sqlalchemy/databases/mssql.py

 
 class MSSQLDialect_pyodbc(MSSQLDialect):
     
+    def __init__(self, **params):
+        super(MSSQLDialect_pyodbc, self).__init__(**params)
+        # whether use_scope_identity will work depends on the version of pyodbc
+        try:
+            import pyodbc
+            self.use_scope_identity = hasattr(pyodbc.Cursor, 'nextset')
+        except:
+            pass
+        
     def import_dbapi(cls):
         import pyodbc as module
         return module