import codecs import dataset db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/google_poi?charset=utf8mb4') table=db['category'] fr=codecs.open('category.csv','r','utf-8') lines=fr.readlines() for l in lines: newl=l.strip() # print(newl) elmts=newl.split(',') table.insert({'keyword':elmts[0],'num':elmts[1],'label':elmts[2]}) #print(lines) fr.close()