Skip to content

Random character is displayed when unicode data is fetched. #157

@sachin-aryal

Description

@sachin-aryal
  1. What is your version of Python? Is it 32-bit or 64-bit?

Python 2.7 and 64-bit

  1. What is your version of cx_Oracle?

6.0.2

  1. What is your version of the Oracle client (e.g. Instant Client)? How was it
    installed? Where is it installed?

11.2.0.4.0
Unzipped and oracle client files and set the environment variables.
/Applications/oracle/product/instantclient_64/11.2.0.4.0/

  1. What is your version of the Oracle Database?
    Oracle is Installed on Docker

Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

  1. What is your OS and version?

os x el capitan version 10.11

  1. What compiler version did you use? For example, with GCC, run
    gcc --version.

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

  1. What environment variables did you set? How exactly did you set them?

export ORACLE_HOME=/Applications/oracle/product/instantclient_64/11.2.0.4.0
ORACLE_SID=xe
export ORACLE_SID
export PATH=$ORACLE_HOME/bin:$PATH
export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib

I am doing something like this in my code

import cx_Oracle
connection_string = "%s:%s/%s" % ("192.168.0.100", "1521", "xe")
connection = cx_Oracle.connect("system", "oracle", connection_string, encoding="UTF-8", nencoding="UTF-8")
cur = connection.cursor()
print ("Connection Version: {}".format(connection.version))
print(connection.encoding)
print(connection.nencoding)
query = "select *from product_information"
cur.execute(query)
records = cur.fetchmany(1000)
for r in records:
    print r
    print (r[2])

I got the output like this

UTF-8
UTF-8
(3, u'testing', 'test-\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd')
test-������������

I am using the following query to create a table in Oracle database

CREATE TABLE product_information 
    ( product_id          NUMBER(6) 
    , product_name        NVARCHAR2(100) 
    , product_description VARCHAR2(1000));

I used the following query to insert data

insert into product_information values(2, 'teting', 'test-दुःख');

Query: SELECT * from NLS_DATABASE_PARAMETERS WHERE parameter IN ( 'NLS_LANGUAGE', 'NLS_TERRITORY', 'NLS_CHARACTERSET');

Result

NLS_LANGUAGE: AMERICAN, NLS_TERRITORY: AMERICA, NLS_CHARACTERSET: AL32UTF8

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions