[reportlab-users] Using reportlab to report on mysql data

John Pywtorak jpywtora at calpoly.edu
Fri Feb 24 14:48:37 EST 2006


As far as I know there is no wizard/generator driven way to spit out 
boilerplate code from a database schema which could show what you say 
below in pdf form using reportlab.  Interestingly I have been using Ruby 
on Rails and I could see a similar sort of meta framework for pdf 
creation.  So, in the python world a $ script/generate pdf_scaffold log 
would use SQLObject and reportlab and create a pdf with the data from 
the table in the database.  Now this would not be for CRUD, but 
hopefully you get the idea.

So, maybe I got off track.  This can be done with relatively easy python 
code.  Just couple the python db-api with platypus tables.  Use the 
SimpleDocTemplate and you should be good to go.  Look at the users guide 
and the mysql python driver.  First reproduce what you have done to a 
terminal with no pdf.  Then throw in the pdf generation code replacing 
your console presentation.

Johnny P
-- 
Windows
Start Here
Frustrating Hanging Crashing
Blue Screen of Death
Reboot

Dukes Clayton wrote:
> (this email is best viewed in text mode)
> Hi,
> I think reportlab will use mysqldata for reporting, right?
> Can someone tell me how I can get started with this?
> Is there an interface somewhere that let's me input what tables to read
> and then writes data based on that?
> 
> What I would like to do is:
> I have a syslog database with several million lines in it.
> I need to generate a script every day to report on the top 10 hosts so I
> do (in mysql of course):
> 
> SELECT host, COUNT(*) as count FROM logs GROUP BY host ORDER BY count
> DESC LIMIT 10;
> 
> Which gives me:
> +--------------+-------+
> | host         | count |
> +--------------+-------+
> | fwfdc-3060   | 62168 |
> | 34222-3060   | 52068 |
> | nandc-3060   | 48771 |
> | nasun-6513   | 34942 |
> | orodc-7325   | 34853 |
> | 32801-3550   | 31342 |
> | CORP-B31     | 28751 |
> | 34703or-1750 | 23544 |
> | 05332-3750   | 23404 |
> | 34325-3060   | 19183 |
> +--------------+-------+
> 
> Of course, I can do this in php and have nicer outputthan the mysql text
> above, but I know diddly about python or reportlab.
> Can someone help me make my boss(es) happy? :-)
> 
> Regards,
> Clayton



More information about the reportlab-users mailing list