mysql.conversion.input.Basic_Conversion

Package mysql :: Package conversion :: Module input :: Class Basic_Conversion |
[hide private]
[frames] | no frames]

# Class Basic_Conversion

source code

    Input_Conversion --+
                       |
                      Basic_Conversion

The default conversion class used if none is specified.

It can handle the following Python types:

- `int`: Returned as-is.
- `long`: Returned as-is.
- `float`: Returned as-is.
- `None`: Converts to "NULL".
- `str`: Escaped string.
- `bool`: Converted to 1 or 0.
- `decimal.Decimal`: Returned as a string.
- `dict`: Comma seperated list of escaped values. (Useful for sets.)
- `list`: Comma seperated list of escaped values.
- `tuple`: Comma seperated list of escaped values.
- `sets.Set`: Comma seperated list of escaped values.
- `datetime.datetime`: `%Y-%m-%d %H:%M:%S`
- `datetime.time`: `%H:%M:%S`
- `datetime.timedelta`: `%H:%M:%S` possibly negative.
- `datetime.date`: `%Y-%m-%d`

For MySQL "BIT" fields, you may use integers, or binary strings (such as '' which has bits 13 and 3 set).

If the type is not known, the default behavior is to first call `str` on the object, and then escape it.

Instance Methods | [hide private]
`` | __init__(self)
`` | convert(self, *values) Convert Python values to strings suitable for MySQL.
`` | _number(self, value)
`` | _bool(self, value)
`` | _none(self, value)
`` | _escape(self, value)
`` | _dict(self, value)
`` | _sequence(self, value)
`` | _datetime(self, value)
`` | _time(self, value)
`` | _timedelta(self, value)
`` | _date(self, value)

Method Details | [hide private]

### __init__(self) (Constructor) | source code

### convert(self, *values) | source code
Convert Python values to strings suitable for MySQL. This method takes a sequence of Python values to convert. It must return a tuple of strings suitable for MySQL, with all appropriate escaping done. Returns: Returns a tuple of strings. Overrides: Input_Conversion.convert (inherited documentation)

### _number(self, value) | source code

### _bool(self, value) | source code

### _none(self, value) | source code

### _escape(self, value) | source code

### _dict(self, value) | source code

### _sequence(self, value) | source code

### _datetime(self, value) | source code

### _time(self, value) | source code

### _timedelta(self, value) | source code

### _date(self, value) | source code