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)
await cur.executemany('INSERT INTO ML.buffer.ClaimListAPI (ClaimID) VALUES (?);', ids)
where ids
is a python list of ints.
I am getting error
TypeError: ('Params must be in a list, tuple, or Row', 'HY000')
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
ids = [1, 2, 3, 4, 5, 6, 10] ids = [ [x] for x in ids]