Inserting data into table from CSV file in MySql

I wanted to have my data persisted in database for analysis, i had the data in a CSV file and i wanted a quick way to get the data into a table in MySql table. I found this simple but effective solution in StackOverflow

I have a sample CSV file below for reference.

The command below can be used to insert data into Mysql table from command line client.

load data local infile ‘~/tmp/example.csv’ into table rental fields terminated by ‘,’ enclosed by ‘”‘ lines terminated by ‘\n’ (col1,col2,col3,col4,col5,col6,col7,col8,col9

—– CSV File Format —–

“data in quotes”,935,78750,1,1,128,data,708,

Leave a comment

Filed under DB

Leave a Reply

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

You are commenting using your 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