Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String data, right truncation while using fast executemany with pyodbc

Tags:

python

pyodbc

I am struggling with

pyodbc.ProgrammingError: ('String data, right truncation: length 636 buffer 510', 'HY000')

while using executeMany() with __crsr.fast_executemany = True. When I remove this line everything works fine.

I am using pyodbc (4.0.30) and MSSQL with ODBC Driver 17 for SQL Server.

My database table looks like 4 columns and each of them is varchar(255).

I already to add this line: crsr.setinputsizes([(pyodbc.SQL_WVARCHAR, 50, 0)]) and add UseFMTOnly=yes to connection string but it didn't work.

Could you guys help me, please? I am already tired of that.

like image 827
Maciek Sienkiewicz Avatar asked Jul 04 '26 21:07

Maciek Sienkiewicz


1 Answers

Check the ODBC Driver you are using in your pyodbc connection string, if it is an old version, errors could be misleading, use for example: driver="{ODBC Driver 17 for SQL Server}"

instead of: driver="{SQL Server}"

like image 197
Bravhek Avatar answered Jul 06 '26 12:07

Bravhek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!