Mike Bernson wrote:
> Database is mysql
> 
> I am having a problem with unicode and binary type.
> 
> I am using an XML parse the return Unicode strings.
> 
> I have a table in mysql with the default character set as utf8
> 
> I set the charset to utf8 in the connect string to charset=utf8
> 
> I am trying to send a unicode string to the Binary column in the table and
> get the following traceback
> 
> What does the python side need to be so that the Binary type case accept 
> the data.
> [...snip...]
> UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in 
> position 37: ordinal not in range(128)

The binary column types are expecting binary data- e.g. str instances, 
not unicode.  The driver is trying to munge your unicode into bytes it 
can send over the wire and failing.  So either encode/decode as utf8 in 
and out of the blob, or, better yet use a Unicode clob type instead and 
Unicode will go in and out automagically.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to