Wednesday, February 6, 2008

SQLinForm Beautification

Thanks to the magic of ORMs, the number of SQL queries I have to write is pleasantly small. For those times when I do have to hack out a beast of a query, it's nice to know SQLInForm is out there.

SQLinForm is a SQL beautifier–like tidy is for HTML: you feed it raw SQL, no matter how munged, cobbled or kludged, and it will produce a nicely formatted version of that query that you can then paste back into your code.

Today, I was playing around with it with queries of varying degrees of complexity and it seemed to handle all of them quite nicely. It supports many common SQL dialects including MS-SQL, Oracle, and MySQL among others. There are quite a few configuration options available, from spacing between tokens, indentation, colorization, etc. It even has presets for "Large SQL", "Small SQL", and "1-Line SQL". Very nifty.

Unfortunately, this app is currently only available via the Web, so no chance of automated code cleanup right now at least. Apparently there used to be a desktop version which is no longer available, though the developer says there will be new version out in March 2008. I really hope there is a nice CLI front-end for it. Heck, I'd even be willing to plunk down a few bucks for something as time saving as this.