<p>How do I write the results from a mysql query to file?  I just need something quick.  Output can be CSV, XML, HTML, etc.</p>

[{'answer_id': 30868, 'author': 'Matt Rogish', 'author_id': 2590, 'author_profile': 'https://Stackoverflow.com/users/2590', 'pm_score': 5, 'selected': True, 'text': '<pre><code>SELECT a,b,a+b \n  FROM test_table\n  INTO OUTFILE \'/tmp/result.txt\'\n  FIELDS TERMINATED BY \',\' OPTIONALLY ENCLOSED BY \'"\'\n  LINES TERMINATED BY \'\\n\'\n</code></pre>\n\n<p>(the docs show INTO OUTFILE up in the SELECT .. portion which may work as well, but I\'ve never tried it that way)\n<a href="http://dev.mysql.com/doc/refman/5.0/en/select.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.0/en/select.html</a></p>\n\n<p>INTO OUTFILE creates a file on the server; if you are on a client and want it there, do:</p>\n\n<pre><code>mysql -u you -p -e "SELECT ..." &gt;  file_name \n</code></pre>\n'}, {'answer_id': 30875, 'author': 'Daren Thomas', 'author_id': 2260, 'author_profile': 'https://Stackoverflow.com/users/2260', 'pm_score': 1, 'selected': False, 'text': "<p>if you have phpMyAdmin installed, it is a nobrainer: Run the query (haven't got a copy loaded, so I can't tell you the details, but it really is easy) and check neer bottom for export options. CSV will be listed, but I think you can also have SQL if you like :)</p>\n\n<p>phpMyAdmin will give CSV in Excels dialect, which is probably what you want...</p>\n"}, {'answer_id': 30957, 'author': 'Farinha', 'author_id': 2841, 'author_profile': 'https://Stackoverflow.com/users/2841', 'pm_score': 1, 'selected': False, 'text': '<p>You can use <a href="http://www.mysql.com/products/tools/query-browser/" rel="nofollow noreferrer">MySQL Query Browser</a> to run the query and then just go to File -> Export Resultset and choose the output format. The options are CSV, HTML, XML, Excel and PLIST.</p>\n'}]
['https://Stackoverflow.com/questions/30856', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2363/']