I have a dataframe data
that contains 13m rows and 8 columns and is 790mb in size. My query below was still running after 45 minutes which seemed like a red flag. I have tried to iterate through each row to insert into my SQL Server table but I am unsure how to efficiently "chunk" the loading to be more efficient. Any help is appreciated!
cnxn = pyodbc.connect("personal connection info here")
cursor = cnxn.cursor()
# Insert Dataframe into SQL Server:
for index, row in data.iterrows():
cursor.execute("INSERT INTO daily_log (Date,Tick,[Open],High,Low,[Close],Adj_close,Volume) values(?,?,?,?,?,?,?,?)",
row.Date, row.Tick, row.Open, row.High, row.Low, row.Close, row.Adj_close,row.Volume)
cnxn.commit()
cursor.close()