diff --git a/MySQLdb/MySQLdb/converters.py b/MySQLdb/MySQLdb/converters.py index 802e145..008921f 100644 --- a/MySQLdb/MySQLdb/converters.py +++ b/MySQLdb/MySQLdb/converters.py @@ -41,6 +41,10 @@ def Thing2Str(s, d): """Convert something into a string via str().""" return str(s) +def Unicode2Str(s, d): + """Convert a unicode object to a string using latin1 encoding.""" + return s.encode('latin') + # Python 1.5.2 compatibility hack if str(0L)[-1]=='L': def Long2Int(l, d): @@ -106,3 +110,6 @@ conversions = { FIELD_TYPE.DATE: Date_or_None, } +if hasattr(types, 'UnicodeType'): + conversions[types.UnicodeType] = Unicode2Str +