Closed jdhowroyd closed 2 years ago
https://github.com/mkleehammer/pyodbc/issues/835 Use setinputsizes() to send as varchar(max).
Thanks for pointing me to the earlier post (and apologies for raising what is essentially the same issue). I confirm that the use of cursor.setinputsize([(pyodbc.SQL_VARCHAR, 0, 0), ]) fixes the issue in the example code (or SQL_WVARCHAR or both). Clearly, a more complex issue deeper down.
Alternative to using setinputsizes()
https://github.com/mkleehammer/pyodbc/issues/835#issuecomment-1047228743
works for me on Mac M2, thx
Thanks for pointing me to the earlier post (and apologies for raising what is essentially the same issue). I confirm that the use of cursor.setinputsize([(pyodbc.SQL_VARCHAR, 0, 0), ]) fixes the issue in the example code (or SQL_WVARCHAR or both). Clearly, a more complex issue deeper down.
Environment
Ubuntu: 20.04.2 LTS amd64 Python: 3.8.2-0ubuntu2 amd64 pyodbc: 4.0.32 driver: ODBC Driver 17 for SQL Server (msodbcsql17) 17.8.1.1-1 amd64 database: Microsoft SQL Server 2019 (RTM-GDR) (KB4583458) - 15.0.2080.9 (X64) Enterprise Edition running on: Windows Server 2019 Datacenter 10.0 (Build 17763: ) (Hypervisor) / ESXi VMWare
Issue
Parameterised queries raise pyodbc.ProgrammingError:
when string data exceeds 2000 characters and the database collation is utf8 encoded.
Looks like an underlying issue with the driver.
Example code
Attached. mssql_test.py.gz
Further details in the doc string!