diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-08-04 10:13:51 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-08-04 10:13:51 -0400 |
| commit | 64f3c097970dd8f2e141ef9bc71c685b19671267 (patch) | |
| tree | 1988faf04b72ffd674d5061d97e2f1ceea0136ea /lib/sqlalchemy/dialects | |
| parent | 0afa28ee3a9699f7a03fbcc8baf01ea873d0c425 (diff) | |
| download | sqlalchemy-64f3c097970dd8f2e141ef9bc71c685b19671267.tar.gz | |
Add note that fast_executemany uses memory
Ideally this would be a per-execution option, or Pyodbc
could perhaps run the data in chunks.
Fixes: #5334
Change-Id: If4a11b312346b8e4c2b8cd38840b3a2ba56dec3b
Diffstat (limited to 'lib/sqlalchemy/dialects')
| -rw-r--r-- | lib/sqlalchemy/dialects/mssql/pyodbc.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/pyodbc.py b/lib/sqlalchemy/dialects/mssql/pyodbc.py index 14eb0adc7..61325585d 100644 --- a/lib/sqlalchemy/dialects/mssql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mssql/pyodbc.py @@ -125,18 +125,22 @@ Fast Executemany Mode The Pyodbc driver has added support for a "fast executemany" mode of execution which greatly reduces round trips for a DBAPI ``executemany()`` call when using -Microsoft ODBC drivers. The feature is enabled by setting the flag -``.fast_executemany`` on the DBAPI cursor when an executemany call is to be -used. The SQLAlchemy pyodbc SQL Server dialect supports setting this flag -automatically when the ``.fast_executemany`` flag is passed to -:func:`_sa.create_engine` -; note that the ODBC driver must be the Microsoft driver -in order to use this flag:: +Microsoft ODBC drivers, for **limited size batches that fit in memory**. The +feature is enabled by setting the flag ``.fast_executemany`` on the DBAPI +cursor when an executemany call is to be used. The SQLAlchemy pyodbc SQL +Server dialect supports setting this flag automatically when the +``.fast_executemany`` flag is passed to +:func:`_sa.create_engine` ; note that the ODBC driver must be the Microsoft + driver in order to use this flag:: engine = create_engine( "mssql+pyodbc://scott:tiger@mssql2017:1433/test?driver=ODBC+Driver+13+for+SQL+Server", fast_executemany=True) +.. warning:: The pyodbc fast_executemany mode **buffers all rows in memory** and is + not compatible with very large batches of data. A future version of SQLAlchemy + may support this flag as a per-execution option instead. + .. versionadded:: 1.3 .. seealso:: |
