473,574 Members | 2,900 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.Datab aseError: 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.conne ct(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.descripti on, I get:

[('COLUMN', <type 'cx_Oracle.STRI NG'>, 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="RUSSI AN_CIS.UTF8"

--
Best regards, Maxim Kuleshov
Jul 19 '05 #1
1 4408
Maxim Kuleshov wrote:
Hello!

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

cx_Oracle.Datab aseError: 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.conne ct(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.descripti on, I get:

[('COLUMN', <type 'cx_Oracle.STRI NG'>, 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
3332
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 features column access by name. This new release adds support for the cx_Oracle, DB2 and adodbapi modules, allowing users to use PDO with a...
7
8378
by: vb_bv | last post by:
Does Pyton PL/SQL programming language of Oracle support? Thx
4
2847
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 MySQLdb for MySQL and cx_oracle for Oracle, but 2 different APIs in the same app is kind of painful. So I have unixODBC that gives me ODBC on Linux....
17
2714
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 exporting a series of tables into one aggregated table as a text file, for import into a mainframe database. The catch is that I'd like to write code...
0
1570
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 cx_Oracle because I have cx_Oracle.so in /usr/share/python2.4/site-packages/ directory. My environment variables are ORACLE_HOME=/usr/lib/oracle and...
8
9914
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 INTO mean (mean_id,mean_eng_txt) VALUES (:id,:mean)""",id=id,mean=mean) I not surprisingly get this error message:
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 messages in both cases, ie. when running with or without -v. While it is possible that cx_Oracle does some extra processing when running Python in...
0
985
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 might be a pretty useful package for you. Download it and let us know what you think! Cheers,
3
2294
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 results on page. The code is working fine on the command line but when executing it on the browser i get the famouse "Premature end of script...
0
1840
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.. and now when we migrated to 10 G its giving problem... Few lines of my script import sys import cx_Oracle
0
7835
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7753
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8265
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7847
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8132
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6500
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3787
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1365
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1096
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.