473,503 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

python 2.3.4, cx_Oracle 4.1 and utf-8 - trouble

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
Jul 19 '05 #1
1 4395
Maxim Kuleshov wrote:
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?


Googling for "varchar2 utf-8" suggests that it's an Oracle's
feature (or issue). varchar2 is allocated in bytes. Finding
out the largest number of bytes per character is left as
an exercise :)

Sergey.

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3325
by: Bryan J Gudorf | last post by:
PDO, an open source python module for interfacing with RDBMS (SQL databases), has now reached 1.2.0! PDO provides an object oriented API, similar to that of ADO or JDBC, to python developers. PDO...
7
8371
by: vb_bv | last post by:
Does Pyton PL/SQL programming language of Oracle support? Thx
4
2843
by: hot.favorite | last post by:
Hi, I'm fairly new to Python so please pardon any dumbness on my part. I plan to write an app in Python that will run on Linux and would need to connect to Oracle and MySQL. I could use...
17
2702
by: dananrg | last post by:
I'm a little confused about what's out there for database modules at: http://python.org/topics/database/modules.html What I'd like to do is use Python to access an Oracle 9.X database for...
0
1561
by: cirudinezidane | last post by:
Hi!! I'd like to install Oracle 10 g express edition over Ubuntu to use with Python 2.4. I have installed Ubuntu, Python 2.4 and Oracle database. I think that I have installed correctly...
8
9907
by: Richard Schulman | last post by:
Sorry to be back at the goodly well so soon, but... ....when I execute the following -- variable mean_eng_txt being utf-16LE and its datatype nvarchar2(79) in Oracle: cursor.execute("""INSERT...
0
170
by: M.-A. Lemburg | last post by:
On 2008-04-30 18:42, Sean Ryan wrote: The -v option only causes Python to print more information to stderr explaining where it is looking for modules. You should be seeing any dynamic loader...
0
979
by: mh | last post by:
I'm pleased to announce the initial release of OraPIG, the Oracle Python Interface Generator. OraPIG generates Python wrapper classes for Oracle packages. If you use Oracle and Python, this...
3
2289
by: Raja | last post by:
Hi, I am trying to write a cgi program which would be executed on browser with Apache server installed. The program would make a connection to a database using cx_Oracle module and display...
0
1836
by: harshakusam | last post by:
Hi All, In my python script i use to run some oracle queries for this i require a library to connect to oracle which is cx_Oracle. When we were using 9i(oracle).. my script was running fine.....
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5596
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.