Mercurial > p > mysql-python > mysqldb-2
diff MySQLdb/converters.py @ 74:80164eb2f090 MySQLdb
This passes all test, yet is still broken and ugly in many ways.
However, a lot of ugliness has been removed.
author | adustman |
---|---|
date | Sat, 20 Feb 2010 04:27:21 +0000 |
parents | c0c00294239b |
children | 3b03cb566032 |
line wrap: on
line diff
--- a/MySQLdb/converters.py Fri Feb 19 02:21:11 2010 +0000 +++ b/MySQLdb/converters.py Sat Feb 20 04:27:21 2010 +0000 @@ -15,6 +15,7 @@ import array import datetime from decimal import Decimal +from itertools import izip __revision__ = "$Revision$"[11:-2] __author__ = "$Author$"[9:-2] @@ -143,6 +144,8 @@ charset = field.result.connection.character_set_name() def char_to_unicode(s): + if s is None: + return s return s.decode(charset) return char_to_unicode @@ -158,8 +161,25 @@ default_encoder, ] +def get_codec(field, codecs): + for c in codecs: + func = c(field) + if func: + return func + # the default codec is guaranteed to work + +def iter_row_decoder(decoders, row): + if row is None: + return None + return ( d(col) for d, col in izip(decoders, row) ) + +def tuple_row_decoder(decoders, row): + if row is None: + return None + return tuple(iter_row_decoder(decoders, row)) +