From 209703c5326439501038124c1272cd82ae9c935f Mon Sep 17 00:00:00 2001 From: adustman Date: Sun, 23 Dec 2001 21:37:33 +0000 Subject: [PATCH] Unicode support. --- MySQLdb/MySQLdb/converters.py | 7 +++++++ 1 file changed, 7 insertions(+) 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 +