#53 Formatting SQL output


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\)


  • John Currier

    John Currier - 2009-03-25

    Those both require a for-purchase license. Are there open source solutions available that generate HTML?

  • John Currier

    John Currier - 2009-03-26

    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.


  • John Currier

    John Currier - 2009-06-15

    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.


  • John Currier

    John Currier - 2010-04-30

    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.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks