Reputation: 23
import MySQLdb
import csv
mydb = MySQLdb.connect(host='localhost',user='root',passwd='root', db='kabir')
cursor = mydb.cursor()
data = csv.reader(file('data.csv'))
#cursor.execute('create table actors(name varchar(20),age integer)')
for row in data:
cursor.execute('INSERT INTO actors(name,age) VALUES(%s %s)' ,row)
mydb.commit()
cursor.close()
Upvotes: 2
Views: 69
Reputation: 695
You didn't specify a comma between %s and %s. Change it to:
cursor.execute('INSERT INTO actors(name,age) VALUES(%s, %s)' ,row)
and try..
Upvotes: 1