GUI Programming with
      Python and Qt

Quick Links

Python index
Database Objects
Kura (now maintained by Peter Bouda)
CGI scripting and MySQL
Python + KDE Tutorial
Python + KDE Resources
PyKDE example programs
Python and Qt2
PyKDE and PyQt news
A population simulation with Stackless Python
Drift: a language simulation in Python
Anonymous CVS access

View the code

This code has been htmlified by vim.



  • 27-03-2000 - Creation

© 2000 Boudewijn Rempt

CGI scripting and MySQL

One of my first projects was the scripting of a small CGI application for my wife, an on-line dictionary of the Valdyan Language. The application consists of a MySQL database, a CGI script for entering, updating and querying data and a report script to generate static html files because Irina doesn't want the whole world to be able to mess with her dictionary!

I already had a similar application written in Free Pascal, and all I did was to translate that application into Python. Since then, several people, beginners just like I was, have expressed an interest in that code, and that's why I present it here, annotated and well.

As you can see from the kpybrowser screenshot below, there are three modules:, and connects to the database and is a very, very simple wrapper around MySQLmodule - which is a fairly old and unsupported binding to MySQL. Nowadays I use MySQLdb, which however returns the queried rows in a different format. is a utility module that contains a lot of functions to simplify the generation of valid html. is the script called by the webserver. It performs the database actions and generates the response forms. Nowadays I would split this into two modules, but it serves its function.

The file is a simple report that exports the contents of the database to html files. The file create_table.sql creates the datamodel, such as it is.