kabir
kabir

Reputation: 23

data is not inserting in my table

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

Answers (1)

bingorabbit
bingorabbit

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

Related Questions