pyodbc utf-8

  • Thread starter Markus Christen
  • Start date
M

Markus Christen

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:
 
H

Hans Mulder

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.

Which encoding does your webpage use?
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()

I think the way forward would be to look at the data your code snippet
receives from the database.

Which datatype do the strings have? Unicode or str or something else?

If the type is str, which encoding do they use?
If this isn't documented, you could at a few strings containing
non-ascii characters to see what codes are used, and compare
them to popular encodings such as uft8, latin1 and cp1252.


Hope his helps,

-- HansM
 
M

Markus Christen

My webpage is using UTF-8 and utf-8 or unicode is on the DB. When i read out this files with Excel, i have no problems with the umlauts. I heared its a problem of pyodbc itself, cause it is only using ascii i think. I found this page here, but it was not really helpful for me. :( maybe i have not understood what this really means...
http://stackoverflow.com/questions/4805267/problem-with-unicode-decoding

maybe you can understand it and you can translate it for a noob. :D


Am Freitag, 7. Dezember 2012 13:16:09 UTC+1 schrieb Hans Mulder:
 
M

Mark Lawrence

My webpage is using UTF-8 and utf-8 or unicode is on the DB. When i read out this files with Excel, i have no problems with the umlauts. I heared its a problem of pyodbc itself, cause it is only using ascii i think. I found this page here, but it was not really helpful for me. :( maybe i have not understood what this really means...
http://stackoverflow.com/questions/4805267/problem-with-unicode-decoding

maybe you can understand it and you can translate it for a noob. :D

Try http://www.joelonsoftware.com/articles/Unicode.html or
http://nedbatchelder.com/text/unipain.html
 
I

Ian Kelly

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()

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.
 
M

Markus Christen

When i look at my output on my webpage, i can see this:
W\xe4denswil
but it have to be this:
Wädenswil
you know now what i can see exactly... im using django and they told me itsa python problem with utf-8. when i turn off debug, i cant see the page, it give me an error 500.
the text "Danke für die..." on the bottom of my page is displayed correct.. the error comes only when an umlaut is to post, out of the raw.
 
M

Markus Christen

When i look at my output on my webpage, i can see this:
W\xe4denswil
but it have to be this:
Wädenswil
you know now what i can see exactly... im using django and they told me itsa python problem with utf-8. when i turn off debug, i cant see the page, it give me an error 500.
the text "Danke für die..." on the bottom of my page is displayed correct.. the error comes only when an umlaut is to post, out of the raw.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top