[Tutor] Handling a Unicode Return using Pyodbc

Tony Pelletier tony.pelletier at gmail.com
Mon Nov 14 22:43:13 CET 2011

Good Afternoon,

I'm writing a program that is essentially connecting to MS SQL Server and
dumping all the contents of the tables to separate csv's.  I'm almost
complete, but now I'm running into a Unicode issue and I'm not sure how to
resolve it.

I have a ridiculous amount of tables but I managed to figure out it was my
Contact and a contact named Robert Bock.  Here's what I caught.

(127, None, u'Robert', None, u'B\xf6ck', 'uCompany Name', None, 1, 0, 327,

The u'B\xf6ck' is actually Böck.  Notice the ö

My problem is I'm not really sure how to handle it and whether or not it's
failing on the query or the insert to the csv.  The Exception is:

'ascii' codec can't encode character u'\xf6' in position 1: ordinal not in

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111114/3088e8d5/attachment.html>

More information about the Tutor mailing list