--- /dev/null
+.. change::
+ :tags: usecase, mssql
+ :tickets: 13152
+
+ Enhanced the ``aioodbc`` dialect to expose the ``fast_executemany``
+ attribute of the pyodbc cursor. This allows the ``fast_executemany``
+ parameter to work with the ``mssql+aioodbc`` dialect. Pull request
+ courtesy Georg Sieber.
# how it's supposed to work
# return await_(self._cursor.setinputsizes(*inputsizes))
+ @property
+ def fast_executemany(self):
+ return self._cursor._impl.fast_executemany
+
+ @fast_executemany.setter
+ def fast_executemany(self, value):
+ self._cursor._impl.fast_executemany = value
+
class AsyncAdapt_aioodbc_ss_cursor(
AsyncAdapt_aioodbc_cursor, AsyncAdapt_dbapi_ss_cursor
"ProgrammingError",
"InternalError",
"NotSupportedError",
+ "SQL_DRIVER_NAME",
"NUMBER",
"STRING",
"DATETIME",
"BinaryNull",
"SQL_VARCHAR",
"SQL_WVARCHAR",
+ "SQL_DECIMAL",
):
setattr(self, name, getattr(self.pyodbc, name))
@property
def pyodbc_fast_executemany(self):
def has_fastexecutemany(config):
- if not against(config, "mssql+pyodbc"):
+ if not against(config, "mssql+pyodbc") and not against(
+ config, "mssql+aioodbc"
+ ):
return False
if config.db.dialect._dbapi_version() < (4, 0, 19):
return False
with config.db.connect() as conn:
- drivername = conn.connection.driver_connection.getinfo(
+ driver_connection = conn.connection.driver_connection
+
+ # for aioodbc, instead of trying to await, just cheat and
+ # use the pyodbc connection
+ if hasattr(
+ driver_connection, "__module__"
+ ) and driver_connection.__module__.startswith("aioodbc"):
+ driver_connection = driver_connection._conn
+
+ drivername = driver_connection.getinfo(
config.db.dialect.dbapi.SQL_DRIVER_NAME
)
# on linux this is something like 'libmsodbcsql-13.1.so.9.2'.