I have adapted this code (posted below to save you the click) to work for me. I have two questions.
1) how do I get the uploader to skip the header row? Right now it will upload the first row out of my CSV which just defines the columns. So an entry into my DB will be "First Name, Last Name, Email" in this example.
2) 2 columns read "First Name" "Last Name" and apparently that space screws it up throwing an error saying there is a problem with my SQL syntax and to check the manual for my version. After playing around with it on my own I found that if I replaced the space with an _ and it worked. So the new column was "First_Name" and "Last_Name". Is there a way to not get the error and also not use the underscore?
import csv
import MySQLdb
mydb = MySQLdb.connect(host='server IP',
user='DB User Name',
passwd='PW for DB user',
db='name of DB')
cursor = mydb.cursor()
csv_data = csv.reader(file('test.csv'))
for row in csv_data:
cursor.execute('INSERT INTO testcsv(First_Name, \
Last_Name,email )' \
'VALUES("%s","%s","%s")',
row)
#close the connection to the database.
mydb.commit()
cursor.close()
print "Done"