Get HTML/XML Output Of Your MySQL Queries.
Join the DZone community and get the full member experience.Join For Free
The mysql command line utility can be used to build databases, manipulate them, etc. It can also be used as an ad-hoc query tool with HTML-snippet output. Consider this code:
mysql -e "SELECT * FROM mytable WHERE somecondition='somevalue'"The resulting output will be a mess of +, - and | characters used to frame boxes around the values. Now consider instead:
mysql -H -e "SELECT * FROM mytable WHERE somecondition='somevalue'"The output of this is
mysql -H < myqueries.sqlNote that no HTML is generated for any query that does not have a result set (like INSERT or UPDATE). Change the -H to a -X to get XML output (without a DTD/XSL description, unfortunately).
Opinions expressed by DZone contributors are their own.