Generate html with the mysql client

September 12, 2013

I’m a big fan of the MySQL command line tool ie the default text client modestly named: mysql. I use it everyday because you can do almost everything with it (DML, DDL, DCL, administrative tasks,…).

It has many options including generate xml or html output.

$ mysql --help | grep "\--html"
 -H, --html          Produce HTML output.

 

So you can easily script it and generate an HTML document:

 

$ mysql -e"SELECT now() as DATE;" --html
<TABLE BORDER=1><TR><TH>DATE</TH></TR><TR><TD>2013-09-11 19:25:41</TD></TR></TABLE>

 

It’s very simple and it’s valid HTML but it is not valid XHTML!

Why, in 2013, a tool generates HTML rather than XHTML ?

One Response to “Generate html with the mysql client”

  1. I have a question : Is your site generated with mysql -html ?