cx_Oracle: Non-ASCII characters handling with different versions
bhell at spamfence.net
Tue Nov 13 17:37:16 CET 2007
I have a problem with the cx_Oracle module (Oracle database access):
On a computer with cx_Oracle version 4.1 (Python 2.4.3, Oracle 10g)
I can get query results consisting of strings including non-ASCII
characters, e.g. the code example below outputs "é 0xe9" (which is
the correct ISO-8859-1 hex code for "é"). On a newer installation
with cx_Oracle 4.3.3 (Python 2.5.1, connecting to the same Oracle
10g server) these characters are interpreted as ASCII (output "e
0x65"). The database encoding is the default (and it's the same DB
in both cases anyways); I have no NLS environment environment
variables set on either system (I'm running cygwin). The HISTORY
file of my more recent cx_Oracle names a few changes related to
character sets, but noone strikes me to be relevant for this case.
There is non-ASCII data strings in a database, and I need to find a
way to get it out correctly.
Is anybody able to help me?
database = cx_Oracle.connect('login/pass at server')
curs = database.cursor()
sql = """SELECT CHR(233) FROM DUAL"""
result = curs.fetchone()
print result, "0x%x" % ord(result)
More information about the Python-list