Can pyodbc handle more than 2100 parameters like mxodbc does? #1332
Replies: 2 comments
-
ODBC driver implementation limits are beyond the scope of pyODBC. |
Beta Was this translation helpful? Give feedback.
-
mxodbc is closed-source, so the only way to know is to ask the authors. However, the package has not seen a release in over 7 years, so I wouldn't have much hope for a reply. The OPENJSON() function in SQL Server 2016+ can be used as a workaround. For example, id_list = list(range(1, 4))
sql = f"""\
SELECT int_col FROM million_rows
WHERE id IN ({', '.join('?' * len(id_list))})
"""
rows = crsr.execute(sql, id_list).fetchall() creates However, if we use
The workaround is id_list = list(range(1, 2201))
id_list_of_dict = [{"id": v} for v in id_list]
sql = """\
SELECT int_col FROM million_rows
WHERE id IN (
SELECT id FROM OPENJSON(?) WITH (id int '$.id')
)
"""
rows = crsr.execute(
sql,
json.dumps(id_list_of_dict, default=str)
).fetchall() |
Beta Was this translation helpful? Give feedback.
-
How does mxodbc handle the bind param, can 'pyodbc' do that?.
mxodbc
is handling more than 2100 bind parameters in the application query, In this use case mxodbc convert query with out band parameters, and it works.Current pyodbc (v4.0.39) Behaviour:
Current mxODBC (egenix-mxodbc v3.3.6) Behaviour:
Beta Was this translation helpful? Give feedback.
All reactions