pyodbc utf-8

Ian Kelly ian.g.kelly at
Fri Dec 7 17:21:19 CET 2012

On Fri, Dec 7, 2012 at 12:41 AM, Markus Christen
<markuschristen84 at> wrote:
> good morning
> i am using pyodbc 3.0.6 for win32 python 2.7.3
> i used it to connect with a MsSql db. Now i have a little problem with the umlaut. i cant change anything in the db and there are umlauts like "ä", "ö" and "ü" saved. so i have to change my view (of django 1.4.1) to change \xfc into ü etc. but how i have to do this?
> on my webpage the umlauts are correct (without helping fonts like ü (ü)). but not the umlauts out read out of my db.
> Here the code i'm using:
> ---------------------------------
>     conn = pyodbc.connect('DRIVER={SQL Server};CHARSET=UTF8;SERVER=MAURITIUS;DATABASE=baan5c;UID=portal;PWD=P0rtalReader')
>     cursor = conn.cursor()
>     cursor.execute("SELECT t_nama, t_bpid FROM ttccom100070 ORDER BY t_nama")
>     rows = cursor.fetchall()
> ---------------------------------
> helping tags like ", 'utf-8'" or something else didnt work till now. have anyone an idea how i can fix this problem? ^^

What *exactly* is the output of this code?  I have a hunch that it is
actually outputting the correct data as a Unicode string, and you are
looking at the repr of the string and misinterpreting it.

More information about the Python-list mailing list