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()
答案 0 :(得分:1)
您没有在%s和%s之间指定逗号。将其更改为:
cursor.execute('INSERT INTO actors(name,age) VALUES(%s, %s)' ,row)
并尝试..