I am using aioodbc
which is basically async pyodbc. My table has only one columns ClaimID
. I am trying to do bukl insert list of ids like [1, 2, ,3 ,4 ,5 ,6 ... n]
(up to 21k)
JavaScript
x
2
1
await cur.executemany('INSERT INTO ML.buffer.ClaimListAPI (ClaimID) VALUES (?);', ids)•
2
where ids
is a python list of ints.
I am getting error
JavaScript
1
2
1
TypeError: ('Params must be in a list, tuple, or Row', 'HY000')
2
How to perform bulk insert of list of ids ?
Advertisement
Answer
executemany
needs [ [1], [2], [3], [4], [5], [6] ... [n]]
So you have to convert it to nested list
JavaScript
1
4
1
ids = [1, 2, 3, 4, 5, 6, 10]
2
3
ids = [ [x] for x in ids]
4