Book HomeManaging and Using MySQLSearch this book

Chapter 20. The Python DB-API

Contents:

Module: MySQLdb

DB-API supports database-independent database access. The MySQL implementation of this API, MySQLdb, can be downloaded from http://dustman.net/andy/python/MySQLdb. It comes with a RedHat RPM Linux installer, a Win32 installer, and a Python script for other platforms. For those other platforms:

  1. Uncompress the .tar.gz file that contains MySQLdb using the commands gunzip FILENAME.tar.gz and tar xf FILENAME.tar.

  2. Change directories into the newly generated MySQLdb directory.

  3. Issue the command: python setup.py install.

The MySQLdb module contains the standard DB-API methods and attributes as well as several proprietary methods and attributes. Proprietary APIs are marked with asterisks.

20.1. Module: MySQLdb

The entry point into the MySQL module is via the MySQLdb.connect( ) method. The return value from this method represents a connection to a MySQL database that you can use for all of your MySQL operations.

20.1.1. Module Attributes

20.1.2. Module Methods

20.1.3. Connection Attributes

20.1.4. Connection Methods

20.1.5. Cursor Attributes

20.1.6. Cursor Methods



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.