Jesper Petersen
Jesper Petersen

Reputation: 77

MySQL insert from a csv file

I have a csv file I want to load into a database, but can't seem to have a row as a value for the insert function

for row in readCSV:

    cur.execute("INSERT INTO IPaddresses(Start) VALUES(row[0])")

I use the module pymysql

Upvotes: 0

Views: 123

Answers (2)

user2301506
user2301506

Reputation: 300

What exactly happens when you run the code? Errors? Unexpected values in your table?

Upvotes: 0

user2301506
user2301506

Reputation: 300

Not sure why you're not using "load data [local] infile". It'd be much easier. Check out the command here: http://dev.mysql.com/doc/refman/5.0/en/load-data.html and someone with a similar problem here Python/MySQL - LOAD DATA LOCAL INFILE

Upvotes: 1

Related Questions