My project is currently using pypyodbc
Python library to connect to DB2 database, my source is a MS SQL server and I need to read data from that and load the data to a DB2 table. The data volume is million rows and I am attempting to use the executemany()
method to load 50 records in one execution but I keep getting the error:
data must be in a list, tuple or row
I did use list
function to typecast my cursor results but it still doesn't work. The data in the result set is in the format [(record1),(record2)]
. The code snippet is as below:
Tried typecasting the sql results set tuple as well
# use pypyodbc to establish a connection - db2_conn.
cur = db2_conn.cursor()
cur.execute('...a query with 10 columns...')
result = cur.fetchmany(50)
insert_query = 'insert into db2_table (col1,col2,col3,...) values (?,?,?,..)'
cur.executemany(insert_query, list(result))
cur.commit()