Friday, August 27, 2010

Mysqldump in csv format

Pull data from mysql table in a simple CSV


Okay - there is a task to pull data from mysql table in a simple csv file to open it quickly to excel. Why do people need such magic - I will never understand, but once the customer has asked, I did.
So, give in to the power of the console and write:
mysqldump -u [USER_NAME] -p "--where=[WHERE]" "--fields-terminated-by=," "--tab=./" [DB_NAME] [TABLE] > [TABLE].txt


So much love (at the output we get two files - one with SQL and the second with CSV)
p.s. directory that runs this command must be open for entries, otherwise it will curse;)

0 Comments:

Post a Comment