Thursday, October 20

Cute HTML reports from psql

Most people are aware that it is possible to dump quite decent HTML reports from Oracle SQL*Plus, but not many people know that the same is also available from PostgreSQL psql tool.

I've written a few scripts and template for a small project and thought it could be fun to share. The framework simply looks in a directory for .sql files and execute them using psql -f FILE.sql and expects the script to spool a file with the same name but the prefix .data.html. It then concatinates the script with a header and footer HTML file to create a pretty report. This is without using any PHP/Perl or server side parsing. Perfect for things like static weekly reports.
Modify the script after your needs and slam it in to cron.

Show example.

Download the basic framework tarball. The docs aren't great tho :)
Included the sample data and query to generate the example.

No comments: