Database Reporting Services in Django or Python
Question: I am wondering if there are any django based, or even Python Based Reporting
Services ala JasperReports or SQL Server Reporting Services?

Basically, I would love to be able to create reports, send them out as emails
as CSV or HTML or PDF without having to code the reports. Even if I have to
code the report I wouldn't mind, but the whole framework with schedules and so
on would be nice!

PS. I know I could use Django Apps to do it, but I was hoping if there was any
integrated solutions or even projects such as Pinax or Satchmo which brings
together the apps needed.

PPS: It would have to work off Postgres

Thanks and Regards

Mark


Answer: "I would love to be able to create reports ... without having to code the
reports"

So would I. Sadly, however, each report seems to be unique and require custom
code.

From Django model to CSV is easy. Start there with a few of your reports.

    
    
    import csv
    from myApp.models import This, That, TheOther
    def parseCommandLine():
        # setup optparse to get report query parameters
    def main():
        wtr= csv.DictWriter( sys.stdout, ["Col1", "Col2", "Col3"] )
        this, that = parseCommandLine()
        thisList= This.objects.filter( name=this, that__name=that )
        for object in thisList:
            write.writerow( object.col1, object.that.col2, object.theOther.col3 )
    if __name__ == "__main__":
        main()
    

HTML is pretty easy -- Django has an HTML template language. Rather than
render_to_response, you simply render your template and write it to stdout.
And the core of the algorithm, interestingly, is very similar to writing a
CSV. Similar enough that -- without much cleverness -- you should have a
design pattern that does both.

Once you have the CSV working, add the HTML using Django's templates.

PDF's are harder, because you have to actually work out the formatting in some
detail. There are a lot of Python libraries for this. Interestingly, however,
the overall pattern for PDF writing is very similar to CSV and HTML writing.

Emailing means using Python's
[smtplib](http://docs.python.org/library/smtplib.html) directly or Django's
[email](http://docs.djangoproject.com/en/dev/topics/email/) package. This
isn't too hard. All the pieces are there, you just need to email the output
files produced above to some distribution list.

Scheduling takes a little thinking to make best use of `crontab`. This --
perhaps -- is the hardest part of the job.

