cx_Oracle not reading LOB correctly

515 views Asked by At

I am trying to read a LOB field in an Oracle 12c database using cx_Oracle. (Specifically, this is an ST_Geometry field I'm getting the well-known text for.) The problem I'm having is that if the value being returned is sufficiently long, the cursor will chop of some of the initial data in the reading process. For example, if I run the following SQL

SELECT SDE.ST_AsText(shape) FROM street_centerline where seg_id = 960897

in a database client like SQL Developer I get:

LINESTRING ( 2720095.00001681 281993.71874480, 2720084.25003831 281969.81262463, [...])

which is what I'm expecting. But if I use cx_Oracle

import cx_Oracle

db = cx_Oracle.connect('...')
c = db.cursor()
shape = c.execute('SELECT SDE.ST_AsText(shape) FROM street_centerline where seg_id = 960897').fetchone()[0]
print(shape.read())

I get:

( 2720095.00001681 281993.71874480, 2720084.250038 [...])

which is missing the geometry type. This only seems to happen when the LINESTRING has an unusually high number of vertices and the LOB is very long. Can anyone think of why this is happening?

0

There are 0 answers