I need to ‘pretty print’ a mysql query. The query is very long and complex and doing this in code is cumbersome. The language doesn’t matter too much, but I am writing a web app so javascript ( to do it client side ) or ruby ( server side ) would be ideal.
Are there any libraries out there that will do this for me?
I imagine it would do something like this…
s = "select foo, bar from baz join bif on baz.id = bif.id where bar = 10"
f= format( s ) # this would return something like the following.
f = "SELECT
foo,
bar
FROM baz
JOIN bif
ON baz.id = bif.id
WHERE bar = 10"
I solved this using the sqlformat web service that appspot offers. I could have written my own web service using the above Sql Beautify method, but I did not want to introduce a new language into our code repository ( we only use ruby, python, and javascript ).