[DB-SIG] probleme with cx_oracle
Jim Patterson
unixdude at gmail.com
Wed Oct 17 16:50:53 CEST 2007
On 10/16/07, yann FORTIER <fortier at atmoauvergne.asso.fr> wrote:
>
> Thanks Jim
> It's wonderful
> All is working.................;
Fabulous, that is good news.
Can you explain me how to inscribe on the mail list on this site
To make the mailing list show the messages on the site, all you
have to do is CC the mailing list address in your messages.
I'll repost the answer I gave you so that future readers can find it.
-----------------------------------
Here is a sample script that I have tested on Windows XP running
Python 2.4.4 using cx_Oracle 4.3.2 connecting a Unicode installation
of Oracle 10G R2:
import os
# Set the environ before importing
os.environ["NLS_LANG"] = ".AL32UTF8"
import cx_Oracle
cxn = cx_Oracle.connect("scott/tiger")
curs = cxn.cursor()
# This is just a sample to get some unicode data
curs.execute(r"SELECT COMPOSE(UNISTR('a\0303')) FROM dual")
row = curs.fetchone()
# You actually get back encoded data in an 8-bit string
raw_col = row[0]
print "Raw string: class=%s, len=%d" % (raw_col.__class__, len(raw_col))
# decode it into something python can use
col = raw_col.decode(cxn.encoding)
import unicodedata
print "Unicode string: class=%s, len=%d, name=%s" % (col.__class__,
len(col), unicodedata.name(col,'.'))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/db-sig/attachments/20071017/24691ee1/attachment.htm
More information about the DB-SIG
mailing list