FormatSql

This library takes SQL and returns (wait for it) formatted SQL.

By Ryan McGreal

Posted September 10, 2009 in Projects (Last Updated September 10, 2009)

I occasionally have to format my SQL queries to meet coding standards (indent this many times, make these keywords uppercase, etc.), and I don't like manually doing stuff that can be automated, so I whipped up this library in Python to do it for me.

Now, you may be thinking that this kind of pattern matching fairly cries out for the use of Regular Expressions, and you'd be right - but I did it the quick and dirty way instead, using string functions. Also, I have Jamie Zawinski on my side. (Yeah, I know.)

This script is the epitome of quick and dirty, as even a cursory glance into the source will confirm, but at least it (more or less) works.

You can download the latest version from the Git repository.

Released under the GNU General Public Licence, Version 2.