Skip to content

Commit 95da375

Browse files
committed
feat: Use Fast Executemany Mode when using the PyODBC SQL Server dialect, closes wireservices/csvkit#1114
1 parent 4eca73d commit 95da375

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Unreleased
22
----------
33

4+
* feat: Use `Fast Executemany Mode <https://docs.sqlalchemy.org/en/20/dialects/mssql.html#fast-executemany-mode>`_ when using the PyODBC SQL Server dialect.
45
* Add Python 3.12 support.
56
* Drop support for Python 3.6 (2021-12-23), 3.7 (2023-06-27).
67

agatesql/table.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import datetime
77
import decimal
8+
from urllib.parse import urlsplit
89

910
import agate
1011
from sqlalchemy import Column, MetaData, Table, UniqueConstraint, create_engine, dialects
@@ -58,7 +59,11 @@ def get_engine_and_connection(connection_or_string=None):
5859
connection = connection_or_string
5960
return None, connection
6061

61-
engine = create_engine(connection_or_string)
62+
kwargs = {}
63+
if urlsplit(connection_or_string).scheme == 'mssql+pyodbc':
64+
kwargs = {'fast_executemany': True}
65+
66+
engine = create_engine(connection_or_string, **kwargs)
6267
connection = engine.connect()
6368
return engine, connection
6469

0 commit comments

Comments
 (0)