Next
/
Previous
/ Index
/ TCC Help System
/ Publications
/ Site map
/ NM Tech homepage
Python Web frontends to database backends
|
|
To illustrate how easy it is to build a Web frontend for a
database using Python's universal database interface, here is
an application for biologists.
- The application area is a system of six-letter codes used
to represent bird species (and genera and families and
subspecies). See the link to
A robust bird code system for an explanation of
how bird names are converted to codes.
- The last link on the above page,
`Look up bird names and codes', uses a MySQL database
backend. Try entering codes like AMEROB (for American
Robin) and HARDUC (Harlequin Duck), or scientific
names like Porzana carolina.
- Several major Python modules are involved in this application:
- Two CGI scripts handle the two forms on the page.
abbrlookup.cgi takes care of looking up codes, and
scilookup.cgi handles lookup of scientific names.
- Both these CGI scripts use a common module named
showtaxa.py that provides
a function named htmlTaxon() that displays the complete
classification of a bird in HTML.
- Module
hier.py represents the system
of taxonomic ranks (e.g, order, family, genus, species, etc.)
used in the classification. This module is actually just an
interface to a short text file,
ranks, whose format is discussed
on the
documentation links on the
base page for the six-letter code system.
The hier.py module is required by the next module,
txny.py.
- Module
txny.py contains the complete
classification of North American birds. To the layers built
on top of it, it looks like a system of persistent objects,
but the persistence is provided by the MySQL layer below.
- The txny.py layer is built on top of my
Python database helper functions.
- The database helper functions are built in turn on top of
Python's universal database applications programming interface
(DBAPI), version 1.0, which is discussed on the
Python database topic guide.
- To get the specific DBAPI that connects to the MySQL
database engine, use:
import MySQLdb
which supports the DBAPI 1.0 interface.
See also: Examples of applications written in Python
Previous: Some Python database helper functions
Site map
Index:
Keyword index
to help pages
Help:
New Mexico Tech Computer Center: Help System
TCC Publications
Home:
About New Mexico Tech
John Shipman, john@nmt.edu
Last updated: 2006/12/07 22:36:39 UT
URL: http://www.nmt.edu/tcc/help/lang/python/web-db.html