Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating cxOracle to numpy type conversion. #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions easyaccess/eautils/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
# Oracle data types
or_n = cx_Oracle.NUMBER
or_s = cx_Oracle.STRING
or_f = cx_Oracle.NATIVE_FLOAT
or_f = cx_Oracle.DB_TYPE_BINARY_FLOAT
or_d = cx_Oracle.DB_TYPE_BINARY_DOUBLE
or_dt = cx_Oracle.DATETIME
or_ts = cx_Oracle.TIMESTAMP
# This is actually OBJECTVAR (hence 'or_ov')
Expand All @@ -47,7 +48,14 @@ def oracle2numpy(desc):
digits = desc[4]
scale = desc[5]

if otype == or_n:
if otype == or_f:
# Binary floats
return "f4"
elif otype == or_d:
# Binary doubles
return "f8"
elif otype == or_n:
# Numbers
# When no scale/digits avaiable, return float
if scale is None and digits is None:
return "f8"
Expand All @@ -71,12 +79,6 @@ def oracle2numpy(desc):
else:
# I didn't know this existed...
return "f16"
elif otype == or_f:
# Native floats
if size == 4:
return "f4"
elif size == 8:
return "f8"
elif otype == or_s:
return "S" + str(size)
else:
Expand Down Expand Up @@ -129,6 +131,9 @@ def numpy2oracle(dtype):
if (kind == 'S'):
# string type
return 'VARCHAR2(%d)' % size
#elif (kind == 'b'):
# # boolean (a bit complicated in Oracle)
# return 'BOOLEAN'
elif (kind == 'i' or kind == 'u'):
if (size == 1):
# 1-byte (8 bit) integer
Expand Down