MySQL Output Converter

While I’m at work I pretty much always have a terminal window open with a MySQL prompt. Whether it’s helping someone troubleshoot an account problem, looking up stats, or gathering data for reports, I run a lot of queries throughout the day.

Oftentimes I want to make a chart with that data, which requires me switching database servers, looking up the MySQL CSV syntax on morgamic’s blog, and scp’ing the CSVs to my laptop.

I’ve grown tired of doing that, and tonight I finally did something about it: MySQL Output Converter

It’s a simple little page that lets you paste your MySQL results that look like this:

mysql> SELECT * FROM word_replacements;
| id | word      | replacement | created             |
|  1 | favourite | favorite    | 2010-01-22 01:06:59 | 
|  2 | centre    | center      | 2010-01-22 01:06:59 | 
|  3 | flavour   | flavor      | 2010-01-22 01:14:30 | 
|  4 | colour    | color       | 2010-01-22 01:14:30 | 
4 rows in set (0.00 sec)

and turn them into this:

"1","favourite","favorite","2010-01-22 01:06:59"
"2","centre","center","2010-01-22 01:06:59"
"3","flavour","flavor","2010-01-22 01:14:30"
"4","colour","color","2010-01-22 01:14:30"

It can also convert the data into an HTML table if it’s going directly to the web. Please feel free to use my copy if it’s useful to you (everything is client-side JavaScript; nothing is sent to the server) or grab your own from the source.

  • Neil Rashbrook

    One database package I used to use had a built-in command UNLOAD ASCII that exported a table to CSV which conveniently also worked on a view, although that did require creating a temporary view for the query and you couldn’t sort the output. (Strangely the equivalent LOAD ASCII wasn’t 8-bit safe.)

  • FACORAT Fabrice

    Interesting to see this support coming to MySQL.

    PostgreSQL support this since a long time :

  • Blake

    I love the convert to HTML table option.

    Recently, I’ve been writing SQL queries directly from R, using the RSQLite package. Highly recommended.