Writing a csv file into SQL Server database using python

后端 未结 5 2053
一向
一向 2020-12-01 00:22

Hi I am trying to write a csv file into a table in SQL Server database using python. I am facing errors when I pass the parameters , but I don\'t face any error when I do it

5条回答
  •  醉梦人生
    2020-12-01 01:00

    You can pass the columns as arguments. For example:

    for rows in csv_data: # Iterate through csv
        cur.execute("INSERT INTO MyTable(Col1,Col2,Col3,Col4) VALUES (?,?,?,?)", *rows)
    

提交回复
热议问题