python 2.3.4, cx_Oracle 4.1 and utf-8 - trouble

Maxim Kuleshov kuleshov at cs.vsu.ru
Fri May 13 01:15:38 EDT 2005


Hello!

Trying to fetch long varchar2 column and get the following error:

cx_Oracle.DatabaseError: column at array pos 0 fetched with error: 1406

i.e. string buffer is not much enough to fetch the string.

# fragment of code...
myCon = cx_Oracle.connect(user, psw, dsn)
myCur = myCon.cursor()
myCur.execute("""
select COLUMN from TABLE where ID=1
""")
for record in myCur.fetchall():
# ...

Error is reproduced only if actual string value longer than half of
declared column size. For short strings all is ok.

If I print myCur.description, I get:

[('COLUMN', <type 'cx_Oracle.STRING'>, 250, 250, 0, 0, 1)]

250 - declared column max size, but I guess cx_Oracle allocates only 250
bytes(!), so if my string longer than 125 chars (utf-8 national char
occupies > 1 byte) - I get the error.

Is it bug or what? Any suggestions?

Extra info:
      OS - SuSE Linux 9.2
      Client - Oracle Client 9.2.0.1.0
      NLS_LANG="RUSSIAN_CIS.UTF8"

--
Best regards, Maxim Kuleshov



More information about the Python-list mailing list