New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random character is displayed when unicode data is fetched. #157
Comments
That data appears to be messed up. Did you insert that string using Python or SQL*Plus? If Python, can you post the script you used? If SQL*Plus, did you make sure you set NLS_LANG=.AL32UTF8 before running SQL*Plus? If I insert that data, ensuring that I inserted it using the UTF-8 encoding, I get the following result when I query it using your code: (2, u'teting', 'test-\xe0\xa4\xa6\xe0\xa5\x81\xe0\xa4\x83\xe0\xa4\x96') That is expected. If I take that result and decode it (product_description.decode("UTF-8")) then I get this result: (2, 'teting', 'test-दुःख') That also happens to be the same result that I get if I use Python 3, which make the whole unicode thing much simpler to manage! :-) |
I insert the data with SQL*PLUS. Where should I set NLS_LANG=.AL32UTF8 ?
I got following output
|
You need to set the environment variable NLS_LANG to the value ".AL32UTF8" prior to executing SQL*Plus. You can usually do this in the following fashion: NLS_LANG=.AL32UTF8 sqlplus If you use Python 3.x you will get the error you noted when you attempt to decode using a string. Using Python 2.x you will not get that error (bytes and str are the same object). |
When I set the NLS_LANG=.AL32UTF8 as the environment variable. It worked perfectly thank you. |
The environment variable can be set, but if you use the parameters encoding = "UTF-8" and nencoding = "UTF-8" when you create your connection in Python that is doing the equivalent thing and you don't need the environment variable. When you use SQL*Plus, though, you always need the environment variable. |
Okay sure. It solved my problem. |
Excellent. |
while retrieving data from table french data is converted to unknown variables Actual data: i have tried setting NLS_LANG also but nothing seems to be working for me. my NLS_DATABASE_PARAMETERS are |
Use a new issue instead of tacking your question on to an old closed issue, please! To briefly answer your question: you should be creating your connection as follows:
You can see more detailed instructions in the documentation. |
Thanks for the reply. I have raised a new issue also. |
Python 3.7.1 i am using |
#----------------------------------------------------------------Modules Create logger instance def oraclesql(datasource, username, password): get host and porthost_port = dsn_conn[0].split(':') create dsndsn_tns = cx_Oracle.makedsn(str(host_port[0]), host_port[1], service_name=str(dsn_conn[1])) |
@arvindsam96 Use a new issue. |
installed? Where is it installed?
Oracle is Installed on Docker
gcc --version
.I am doing something like this in my code
I got the output like this
I am using the following query to create a table in Oracle database
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
The text was updated successfully, but these errors were encountered: