-
Notifications
You must be signed in to change notification settings - Fork 361
Closed
Labels
Description
Hi,
we are using cx_Oracle for export data from Oracle database. It is working pretty good but today we have a problem with wrong float values returning from our user defined type. We have these two types:
CREATE OR REPLACE TYPE geomext AS OBJECT (
x DOUBLE PRECISION,
y DOUBLE PRECISION,
rotation DOUBLE PRECISION,
deg_start DOUBLE PRECISION,
deg_sweep DOUBLE PRECISION,
prim_axis DOUBLE PRECISION,
sec_axis DOUBLE PRECISION,
width DOUBLE PRECISION,
height DOUBLE PRECISION,
justification INTEGER,
font VARCHAR2 (255 CHAR),
text VARCHAR2 (1000 CHAR)
);
CREATE OR REPLACE TYPE geomext_array AS
VARRAY (10000) OF geomext;In SQL developer we are able to get correct values. The output from SQL developer for geomext object:
GEOMEXT(0,0,0.314937,0,0,0,0,0,0,2,NULL,'01/2000')
Here is how we get values via cx_Oracle:
# Reading object values with this method
def ObjectRepr(obj):
if obj.type.iscollection:
returnValue = []
for value in obj.aslist():
if isinstance(value, cx_oracle.Object):
value = ObjectRepr(value)
returnValue.append(value)
else:
returnValue = {}
for attr in obj.type.attributes:
value = getattr(obj, attr.name)
if value is None:
returnValue[attr.name] = 'NULL'
elif isinstance(value, cx_oracle.Object):
value = ObjectRepr(value)
returnValue[attr.name] = value
return returnValue
dsn = cx_oracle.makedsn(or_host, or_port, or_sid)
conn = cx_oracle.connect(user=or_user, password=or_password, dsn=dsn)
cursor = conn.cursor()
data = cursor.execute("SELECT id,geomext FROM geom_table").fetchall()
for insert in data:
for col in insert:
if isinstance(col, cx_oracle.Object):
values = ObjectRepr(col)
print(values)But print statement for 0 value returns 1.619e-319 and for 0.314937 returns 8.10513527767e-313. Both are <class 'float'> types.
Python 3.6.2 64-bit
cx_Oracle - version 6.1.2 - upgraded from pip today
Oracle client - version 12.1.0.2.0
Oracle Database 12c Enterprise Edition
Windows 7 - 64-bit