with open('employee.txt') as textfile:
csvreader = csv.reader(textfile, delimiter='\t')
csvdata = []
for row in csvreader:
csvdata.append(row)
conn = pymysql.connect (host = "localhost",user = "root", passwd = "password",db = "details1")
c = conn.cursor()
for row in csvdata:
c.execute("INSERT INTO employee6(serial_no, first_name, last_name, age, sex,city) VALUES ('%s', '%s', '%s', '%s', '%s','%s')" % (serial_no,first_name,last_name,age,sex,city))
conn.commit()
c.close()`enter code here`
but I am getting an error in () 8 c = conn.cursor() 9 for row in csvdata: ---> 10 c.execute("INSERT INTO employee6(serial_no, first_name, last_name, age, sex,city) VALUES ('%s', '%s', '%s', '%s', '%s','%s')" % (serial_no,first_name,last_name,age,sex,city)) 11 12 conn.commit() NameError: name 'serial_no' is not defined why am i getting this error
print(row)pleaseprint(row)if possible. ANd that would the therowabouve yourc.execute()line. That's kind of relevant for the answer.