Chapter 16. Using MySQL Stored Programs with Python
Python is an open source, object-oriented, cross-platform language commonly used for system administration, application development, and many other purposes. Python is often used in very similar types of applications as Perl. However, Python devotees believe that Python offers many advantages over Perl in that it is natively object oriented, results in more readable and maintainable code, and enables greater programmer productivity, especially for large-scale developments. (Perl devotees have a different opinion, of course!)
The Python language includes a specification for a
vendor-independent database-access API, the Python Database API
Specification v2.0. You can find the specification for this API at
http://www.python.org/peps/pep-0249.html. The
MySQL implementation of this API is called MySQLdb , and is available at http://sourceforge.net/projects/mysql-python.
In this chapter we will review how to interact with a MySQL
database using Python and the MySQLdb
module, and explain how to exploit MySQL stored programs through this
interface.
Installing the MySQLdb Extension
You can obtain the MySQLdb module for Python at http://sourceforge.net/projects/mysql-python. For
Windows users, the MySQLdb module is packaged as a Windows executable. For Linux or Unix users, the module is packaged as a gzip tar archive; you should download the archive and, after unpacking it, run the following commands in the root directory of the archive ...