I connect from Python 2.7 to Oracle data base.
When I use:
cursor.execute("SELECT column1 FROM table").fetchall()]
I have got almost proper values for column1 because all Polish characters ("ęóąśłżćń") are converted to ascii one ("eoaslzcn"). Using another tool like SQLDeveloper and using the same select statement I get proper value.
Try setting the environment variable NLS_LANG
to your database language string, something like
os.environ['NLS_LANG'] = 'POLISH_POLAND.EE8MSWIN1250'
@Mark Harrison - thank you very much ! It works! There is an exact instruction what I did:
I checked in Oracle what is the language:
SELECT USERENV ('language') FROM DUAL
The response was:
POLISH_POLAND.UTF8
Then I changed NLS_LA value in Python:
os.environ['NLS_LANG'] = 'POLISH_POLAND.UTF8'
Using
print "%s, %s" % (name, surname)
and "> file.txt" in command line I obtained a (proper) file in utf8.