python - Setting query results encoding in cx_Oracle / UnicodeDecodeError with Chinese characters -
i'm working database containing lot of chinese characters. code goes this:
connection = cx_oracle.connect("%s/%s@%s:%s/%s" % (username, password, host, port, service_name)) cursor = connection.cursor() cursor.execute('select hotel_id,create_time,source,content,title,rate,update_time t_fx_comments') row in cursor: # stuff goes here pass but error:
traceback (most recent call last): file "test.py", line 17, in <module> row in cursor: unicodedecodeerror: 'gbk' codec can't decode byte 0xaf in position 26: illegal multibyte sequence it seems gbk not enough. i want make cx-oracle give me gb18030 encoded results, instead of gbk. how do this?
cx_oracle.connection.encoding read-only... haven't found in cx-oracle documentation suggests can this.
i'm on python 3.3.2 , cx-oracle 5.1.2. there must i'm missing here. appreciated!
i facing same issue , solved setting environment variable nls_lang .al32utf8 (it seems sort of "wildcard" says "use utf-8 language")
Comments
Post a Comment