The output of the SQL Code (views) is almost unredable. It would be nice to format the SQL (like http://www.sqlinform.com/ or http://www.dpriver.com/pp/sqlformat.htm\)
Those both require a for-purchase license. Are there open source solutions available that generate HTML?
I found an open source Java project for SQL code formatting (no hightlighting): http://code.google.com/p/simplesqlformatter/
Unfortunately that's distributed under a creative commons non-commercial license and doesn't generate HTML. It shouldn't be too difficult to do something similar. One issue, however, is that everyone has their own idea about what formatting approach is readable. The current approach assumes that the SQL in the view is formatted in a style that was deemed appropriate by the DBA.
I looked more closely at http://www.dpriver.com/pp/sqlformat.htm and realized that most of these types of tools will build a parse tree of the SQL and then apply the formatting to that tree. That site, for example, wouldn't render some MySQL views that I have until I explicitly stated to use its MySQL parser.
I'm hoping that this could be done in a database-independent manner, but that's beginning to appear unlikely.
The latest beta version attempts to detect that the view SQL has already been formatted and presents it in it's original form when it is. Databases may or may not retain the original author's formatting details (MySQL does not), so it might be a pointless attempt.
There are a few open source projects that attempt to do this type of formatting, but the task basically requires a complete project to do it. I've added a -sqlFormatter command-line option to let you plug-in your own formatter if desired.
Log in to post a comment.