Environment
To diagnose, we usually need to know the following, including version numbers. On Windows, be
sure to specify 32-bit Python or 64-bit:
- Python: 3.6.3
- pyodbc: 4.0.23
- OS: Debian Stretch
- DB: SQL Server
- driver: Microsoft ODBC Driver 17 for SQL Server libmsodbcsql-17.0.so.1.1
Issue
When executing a parameterized "UPDATE" statement with fast_executemany, the following exception is thrown.
ERROR - encoding with 'utf-16le' codec failed (SystemError: <built-in function utf_16_le_encode> returned a result with an error set)
pyodbc.ProgrammingError: ('String data, right truncation: length 666 buffer 510', 'HY000')
The column widths in the target database have more than enough size to hold the data.
This seems equivalent to Issue #337 except that in this case, I'm using 4.0.23 of pyodbc and MS ODBC Driver 17, which fixed the issue in that post but continue to be a problem for me.
I've trimmed down the data to just two rows and can consistently reproduce the problem with just those two rows.
I'm using SQL Alchemy to construct the statements and am using the connection.execute(stmt, [row1, row2]) method to execute.
Turning fast_executemany off fixes the problem, but unacceptably impacts performance.
Environment
To diagnose, we usually need to know the following, including version numbers. On Windows, be
sure to specify 32-bit Python or 64-bit:
Issue
When executing a parameterized "UPDATE" statement with
fast_executemany, the following exception is thrown.The column widths in the target database have more than enough size to hold the data.
This seems equivalent to Issue #337 except that in this case, I'm using 4.0.23 of pyodbc and MS ODBC Driver 17, which fixed the issue in that post but continue to be a problem for me.
I've trimmed down the data to just two rows and can consistently reproduce the problem with just those two rows.
I'm using SQL Alchemy to construct the statements and am using the
connection.execute(stmt, [row1, row2])method to execute.Turning
fast_executemanyoff fixes the problem, but unacceptably impacts performance.