Attributes

Attributes can be available to the entire module, or they can be specific to a cursor. This section describes the available attributes according to how they are available.

Module Attributes

These attributes are available to the entire module.

apilevel

A string constant containing the supported version of the DB-API (2.0 if you're using the version 2.0, for example).

conv

Maps MySQL types to Python objects. This defaults to MySQLdb.converters.conversions.

paramstyle

A string constant containing the type of parameter marker (placeholder) formatting that the interface uses. This can be format, for example:

...WHERE fieldname=%s

or it can be pyformat, for example:

 ...WHERE fieldname=%(name)s 

threadsafety

An integer constant containing the level of thread safety. It can be 0 (no thread sharing), 1 (threads can share the module only), 2 (threads can share the module and the connections), or 3 (threads can share the module, connections, and cursors). The default is 1.

Cursor Attributes

These attributes are specific to a cursor object, returned from the cursor() method.

Arraysize

Specifies the number of rows returned by the fetchmany() method, and affects the fetchall() method's performance. This defaults to 1, or one row at a time.

Description

This attribute is read only and is a sequence of sequences describing the columns in the current result set, each with seven items. These are name, type_code, display_size, internal_size, precision, scale, and null_ok.

The name and type_code items are mandatory, and the rest are set to None if there are no meaningful values for them.

This is set to None if the query does not return any rows or has not yet been invoked.

Rowcount

This attribute is read only, and it indicates the number of rows the last query affected or returned, or it returns –1 if the number of rows is unknown or a query has not been invoked.



Mastering MySQL 4
Mastering MySQL 4
ISBN: 0782141625
EAN: 2147483647
Year: 2003
Pages: 230
Authors: Ian Gilfillan

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net