You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When inserting a sequence of Integers using .executemany(), ctds assumes the wrong data type, if the first integer is small.
Example:
CREATE TABLE TestTable
(
Number INT NULL,
)
with ctds.connect('server', database='database') as con:
with con.cursor() as cursor:
data = [(1,), (30000,), (0, )]
query = 'INSERT INTO TestTable (Number) VALUES (:0)'
cursor.executemany(query, data)
con.commit()
leads to" _tds.DataError: Error converting data type smallint to tinyint.".
The reason is the created INSERT Statement, which assumes datatype tinyint for this column, as we can see in SQL Server Profiler:
exec sp_executesql N'INSERT INTO TestTable (Number) VALUES (@param0)',N'@param0 TINYINT',1
go
exec sp_executesql N'INSERT INTO TestTable (Number) VALUES (@param0)',N'@param0 TINYINT',30000
go
The text was updated successfully, but these errors were encountered:
System Specs:
When inserting a sequence of Integers using .executemany(), ctds assumes the wrong data type, if the first integer is small.
Example:
leads to" _tds.DataError: Error converting data type smallint to tinyint.".
The reason is the created INSERT Statement, which assumes datatype tinyint for this column, as we can see in SQL Server Profiler:
The text was updated successfully, but these errors were encountered: