views:

890

answers:

2

Hi,

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

+3  A: 

"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 directly or Django's 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.

S.Lott
Thanks for your response! If I manage to get the time, I might start a pinax/satchmo type project but for reporting!Think about it!You have crontab, some html to pdf writer app, some kind of app to store the views as reports and to allow them to be scheduled.If you have some more ideas let me know!
Mark Ellul
+2  A: 

Hi

I just thought after a fair bit of investigation I would report my findings...

http://code.google.com/p/django-reporting/ - I think that this project, looks like an awesome candidate for alot of the functionality I require. Unfortunately its Django 1.1 which as of this writing (29th April 2009) has not been released.At least in the ability to create reports without too much code.

http://code.google.com/p/django-cron/ - Look promising for scheduling of jobs without cron access

http://www.xhtml2pdf.com/ - Could be used or ReportLabs PDF Libraries for conversion of HTML to PDF

All these together with Django's Email functionality could make a nice Reporting System.

Mark Ellul
Very important remark: XHML2PDF/Pisa is licensed under GPL
Sorin Sbarnea
Commercial license is currently 500 EUR.
Sorin Sbarnea
Thanks for your responses Sorin
Mark Ellul