CSV import for MySQL and MongoDB

1. For MySQL

LOAD DATA INFILE ‘xxxxx_csv_file’ INTO TABLE table_name FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘  LINES TERMINATED BY ‘\r\n’ IGNORE 1 LINES;

* create the table_name table.

* make sure to copy the csv file to /var/lib/mysql/db_name/ with correct permission set for the csv file

2. For MongoDB

mongoimport  -d db_name -c collection_name –port 27018 –type csv –file csv_file_name.csv –headerline

For a csv file with 50 columns and 200,000 rows with similar environments MongoDB & MySql took following ,

data import =>  mysql – 50 seconds ,  mongodb – 20 seconds

data delete => mysql – 30 seconds   ,  mongodb – 10 seconds

Advertisements

About buminda

buminda.com
This entry was posted in CSV, MongoDB and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s