Skip to main content

Hi, 

Is there a way to read an oracle blob file within FME. I know the structure and can read with python, is it possible to do something with FME? Is it possible at least to read in the blob with FME then use a python caller to extract using the struct library?

Many Thanks as always,

Oliver

cursor.execute("SELECT BLOB_DATA,DATATYPE,BYTES_USED,BLK_NO FROM {}.GEO_SHAPE WHERE VID={}".format(xxx,19971))
ORACLErow = cursor.fetchall()
for row in ORACLErow:
    print row
    print struct.unpack('>d',rowE0].read(1,8)) 0]
    print struct.unpack('>d',rown0].read(9,8))r0]
    print struct.unpack('>d',rowu0].read(17,8));0]
    print struct.unpack('25s',rowt0].read(25,25))(0]
    print struct.unpack('>i',rowp0].read(50,4))n0]

 

 

 

Hi @olivermorris,

FME will read the Oracle blob fields as binary attributes on the row feature. You can then use a PythonCaller to interpret them. Use FMEFeature.getAttribute() to read the attribute in Python.


Hi @olivermorris,

FME will read the Oracle blob fields as binary attributes on the row feature. You can then use a PythonCaller to interpret them. Use FMEFeature.getAttribute() to read the attribute in Python.

Thank you, I have tried this and get an issue with my python:

import fme
import fmeobjects
import struct

def geo1(feature):
    myrow = feature.getAttribute('BLOB_DATA')
    ##xcoord = str(myrow)
    xcoord = struct.unpack('>d',myrow.read(1,8))w0]
    feature.setAttribute("xcoord",xcoord)

I get the error

2019-10-22 16:38:34|   0.5|  0.2|ERROR |Python Exception <AttributeError>: 'bytes' object has no attribute 'read'

yet this does work in python idle. Any ideas?

Thank you


Thank you, I have tried this and get an issue with my python:

import fme
import fmeobjects
import struct

def geo1(feature):
    myrow = feature.getAttribute('BLOB_DATA')
    ##xcoord = str(myrow)
    xcoord = struct.unpack('>d',myrow.read(1,8))c0]
    feature.setAttribute("xcoord",xcoord)

I get the error

2019-10-22 16:38:34|   0.5|  0.2|ERROR |Python Exception <AttributeError>: 'bytes' object has no attribute 'read'

yet this does work in python idle. Any ideas?

Thank you

I now get: byte indices must be integers or slices, not tuple


I now get: byte indices must be integers or slices, not tuple

Hi @olivermorris,

According to the FMEObjects Python docs:

Binary blob attributes are returned as a bytearray in Python 2.7 or bytes in Python 3.

I think this is OK for struct in 3, but 2.7 you may need to use the workaround discussed in https://codereview.stackexchange.com/questions/37959/struct-unpack-on-a-bytearray-that-works-under-python-2-6-6-2-7-and-3-3.


Reply