- Notifications
You must be signed in to change notification settings - Fork 362
Closed
Labels
Description
I have the following simple code for python (version 3.6.1 x64 Windows):
# -*- coding: utf-8 -*- import cx_Oracle import os os.environ["NLS_LANG"] = "RUSSIAN_RUSSIA.AL32UTF8" conn = cx_Oracle.connect("user/pass@//host:1521/dbname") cur = conn.cursor() print(cx_Oracle.__version__) print(conn.encoding) print(conn.nencoding) cur.execute("select 'Значение' from dual") res = cur.fetchone() cur.close() conn.close() print(res) With cx_Oracle version 5.3 it works as expected and gives the following output:
5.3 UTF-8 UTF-8 ('Значение',) But with the 6.02b version it becomes broken.
- It throws exception about unicode character in query:
6.0b2 ASCII ASCII Traceback (most recent call last): File "C:/Users/SBT-Chernopyatov-AS/PycharmProjects/CUP_Fetcher/ptest_602.py", line 15, in <module> cur.execute("select 'Значение' from dual") UnicodeEncodeError: 'ascii' codec can't encode characters in position 8-15: ordinal not in range(128) - If we fix it by using ".encode('utf8')" or by changing query to "select * from table_with_unicode_data", it gives '????????' for output.
- If we try to get back 'UTF-8' in connection.encoding by adding "encoding='UTF-8'" we get:
Traceback (most recent call last): File "C:/Users/SBT-Chernopyatov-AS/PycharmProjects/CUP_Fetcher/ptest_602.py", line 7, in <module> conn = cx_Oracle.connect("user/pass@//host:1521/dbname", encoding='UTF-8') cx_Oracle.DatabaseError: DPI-1005: unable to acquire Oracle environment handle So, seems there is no way to work with the unicode strings right now.