Converting Perl Web Report to Python

pmcgover at pmcgover at
Sat Sep 23 09:04:16 EDT 2006

I enjoyed Paul Barry's September article in Linux Journal entitled,
"Web Reporting with MySQL, CSS and Perl".  It provides a simple,
elegant way to use HTML to display database content without any sql
markup in the cgi script.  The cgi script simply calls the Mysql
command line with the HTML option (-H) and the SQL script file directed
to that command.  This provides complete separation of the markup from
the sql code.  The plain vanila HTML output can be spruced up with CSS
to provide more color and size control of the HTML.

Could this script be easily converted to Python?  How would you execute
the Msql command line and direct the output to a variable for display
in the cgi script?  Would it be possible to easily enhance this script
by allowing the user to pass in an SQL query parameter to the sql
script?  I attempted this in Perl by substituting the string "p_1" in
the where clause of the sql code but I could not substitute this string
with the value in the cgi code (ie. $query =~ s/p_1/value_variable/;).
Perhaps it would be easier in Python?

Also, would the user supplied parameter be a security issue?

Below is a link to the article:

More information about the Python-list mailing list