cx_Oracle and UTF8
Gerhard Häring
gh at ghaering.de
Thu Feb 23 09:05:51 EST 2006
Harald Armin Massa wrote:
> Dietz,
>
> thank you for your answer.
>
>>It's called NLS (national language support),
>>and it is like a locale-setting in python/C. I'm too lazy to google right
>
> Sad thing: I allready googled that and had to learn: you CAN definitely
> change some parameters, that is sort order and language for error
> messages with
> alter session set NLSREGION and set NLSLANGUAGE
>
> The only part about the charset is with NLSLANG, which could be set to
> German_Germany.UTF8
>
> BUT ... NLSLANG is no per-session parameter, not setable per alter
> session, it needs to get set within the environment to make SQLPLUS
> recognize it. (and, I do of course use python not sqlplus= [...]
This is handled by the OCI, which both your Pyhton interface and SQLPLUS
use. You should be able to do something like:
import os
os.environ["NLS_LANG"] = "German_Germany.UTF8"
import cx_Oracle
con = cx_Oracle.connect("me/secret at tns")
cur = con.cursor()
cur.execute("select foo from bar")
print cur.fetchone()[0]
HTH,
-- Gerhard
More information about the Python-list
mailing list