[DB-SIG] Parameters, setinputsize and cx_Oracle
Jon Franz
jfranz at neurokode.com
Fri Nov 21 14:48:40 EST 2003
Hello,
I seem to be having some issues with LONG fields
when using cx_Oracle. Specifically, it is behaving as if
.setinputsizes() is not being called, or is being called with
a different value then what was passed - resulting in truncated
data. I hope I'm just doing soemthign wrong.
The really odd part is, the truncation size isn't always the
same - but I'll get to that in a moment. First, my platform:
Windows XP pro, Oracle enterprise 9i, Python 2.3.2,
cx_Oracle 3.1
Now, some examples:
Python 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> mycon = cx_Oracle.connect("cx_Oracle","dev","PDOTEST")
>>> cursor = mycon.cursor()
>>> bigtext = "123456789z" * 9000
>>> len(bigtext)
90000
>>> cursor.setinputsizes(big = len(bigtext))
{'big': <StringVar object at 0x008E65E0>}
>>> cursor.execute("INSERT INTO TESTLONGS (INTCOL, LONGCOL) VALUES (111,
:big)",
{ "big" : bigtext })
>>> cursor.setoutputsize(200000) # bigger than needed
>>> cursor.execute("SELECT * FROM TESTLONGS WHERE INTCOL = 111")
[<NumberVar object at 0x008EB338>, <LongVar object at 0x008E69A0>]
>>> row = cursor.fetchone()
>>> len(row[1])
24464
>>>
----------
Now, at first I thought I was doing something wrong with
.setoutputsize() - but the examples I'm finding do things
the same way - and using the form of
.setoutputsize(200000, 2) (as seen within the LongVar.py
test script from the source dist) has the same problem.
If I commit and examine the row within Oracle Enterprise
Manager, I get the same length as above for the row - so
that leads me to believe I'm not doing something wrong pulling
data out, but something is going wrong on the way in...
Each time I try this, I get the same results, a truncated value -
but the length is not always 24464: sometimes it is 48032 - so
it is not consistently 24464.
Am I doing something wrong at insert time, or somewhere else?
Note: passing a dict to setinputsizes() results in these same problems.
~Jon Franz
NeuroKode Labs, LLC
More information about the DB-SIG
mailing list