Unable to load data from csv file to MySQL table using Python -


i wrote following code dumping large data of earthquake records in .csv file mysql table using python:

import mysqldb import os import string  db = mysqldb.connect (host="111.100."123.134",port=3306,user="root",\                   passwd="****",db="mydb") print "\nconnction db established\n" cursor=db.cursor()  sql = """load data local infile 'all_week.csv' \      table eq_records \      fields terminated ',' \      optionally enclosed '"'  \      lines terminated '\r\n' \      ignore 1 lines;;"""  try:     cursor.execute(sql)     db.commit()     print "data loading complete.\n" except:     print "error in loading data\n" 

this code executing fine table eq_records in mysql workbench empty. please let me know solution this.

i executed same code , got data mysql table. disconnected client connection , connected again , refreshed db , worked.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -