This module handles all the type conversions for MySQL. If the default
type conversions aren't what you need, you can make your own. The
dictionary conversions maps some kind of type to a conversion function
which returns the corresponding value:
Key: FIELD_TYPE.* (from MySQLdb.constants)
Conversion function:
Arguments: string
Returns: Python object
Key: Python type object (from types) or class
Conversion function:
Arguments: Python object of indicated type or class AND
conversion dictionary
Returns: SQL literal value
Notes: Most conversion functions can ignore the dictionary, but
it is a required parameter. It is necessary for converting
things like sequences and instances.
Don't modify conversions if you can avoid it. Instead, make copies
(with the copy() method), modify the copies, and then pass them to
MySQL.connect().
Function Summary
array2Str(o,
d)
char_array(s)
Float2Str(o,
d)
Instance2Str(o,
d)
Convert an Instance to a string representation.
Long2Int(s,
d)
Convert something into a string via str().
Thing2Literal(o,
d)
Convert something into a SQL string literal.
Thing2Str(s,
d)
Convert something into a string via str().
Unicode2Str(s,
d)
Convert a unicode object to a string using the default encoding.
Variable Summary
dict
conversions = {<type 'str'>: <function Thing2Literal at ...
Function Details
Instance2Str(o,
d)
Convert an Instance to a string representation. If the __str__()
method produces acceptable output, then you don't need to add the
class to conversions; it will be handled by the default
converter. If the exact class is not found in d, it will use the
first class it can find for which o is an instance.
Long2Int(s,
d)
Convert something into a string via str().
None2NULL(o,
d)
Convert None to NULL.
Thing2Literal(o,
d)
Convert something into a SQL string literal. If using
MySQL-3.23 or newer, string_literal() is a method of the
_mysql.MYSQL object, and this function will be overridden with
that method when the connection is created.
Thing2Str(s,
d)
Convert something into a string via str().
Unicode2Str(s,
d)
Convert a unicode object to a string using the default encoding.
This is only used as a placeholder for the real function, which
is connection-dependent.