Closed chad-ongstad closed 6 years ago
This is due to the implementation of executemany
, which internally uses sp_executesql
for better performance (and to avoid the possibility of SQL injection). The sequence in the parameter set is used to determine the SQL type to declare for each of the parameters passed to sp_executesql
. in this case, you have a string of length 1, so the type is inferred as CHAR(1)
. Of course later items in the parameter set may have values longer than 1 character and are truncated.
It should be fairly easy to default to SQL type inference to default to the largest widths of the variable sized SQL types for this case. In the meantime, you could explicitly specify the SQL type for the string columns using a type wrapper such as: https://zillow.github.io/ctds/types.html#ctds.SqlNVarChar
Alternatively passing the INT
columns as Python int
(or long
) objects would also avoid the truncation issue.
Fixed in v1.8.0.
Thank you!! This is definitely the fastest python sql server library out there.. I wish I had the c programming background so I could help.
Chad
Sent from my iPhone
On Sep 7, 2018, at 5:53 PM, joshuahlang notifications@github.com<mailto:notifications@github.com> wrote:
Fix in v1.8.0.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/zillow/ctds/issues/25#issuecomment-419586952, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AebiKhjOuhMy_DpH7DcMbd5_Q_qteqSJks5uYvjSgaJpZM4V9gx1.
I seem to get 2 different result sets when using executemany vs. execute when inserting data. I have included an example below that shows how the last 3 records insert differently using execute vs. execute many. I am happy to help out if you can point me in the right direction in the code base. Thanks,
Chad
Returns the following