comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » IDL to Python bridge and "file-like" Python object
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
IDL to Python bridge and "file-like" Python object [message #93236] Tue, 17 May 2016 06:54 Go to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
I am trying to use the FDB Python library through IDL in order to access data from some Firebird databases. Everything works very well and transparently as long as data are simple scalar fields in the database.

When the data field to be read is a so called BLOB field (in my case, a binary block of 10240 bytes), the FDB library exposes it as a Python "file-like object", which can be accessed through seek,tell or read functions. Unfortunately, the use of those functions from the imported IDL object looks like to always return empty strings.

More explicitely, after connecting and executing my SQL statement:

IDL> fdb = Python.Import('fdb')
IDL> con = fdb.connect(dsn=...)
IDL> cur = con.cursor()
IDL> cur.execute('SELECT EVT_ID,EVT_TIME,VOLTS FROM SELECT_EVENT(707208)')

I can fetch the data, while specifying that the third field is a blob:
IDL> print, cur.set_stream_blob('VOLTS')
IDL> r = cur.fetchone()

The retrieving in IDL is successfull and, as expected, I get 3 field values:
IDL> help,r
R LIST <ID=117 NELEMENTS=3>
IDL> r
[
43630,
datetime.datetime(2015, 4, 26, 18, 9, 2, 963700),
<fdb.fbcore.BlobReader object at 0x000000002CCD0FD0>
]

The third element r[2] is indeed retrieved as a Python callable object, but in trying to read it, I get:

IDL> print, r[2].tell()
0
IDL> q = r[2].read()
IDL> print, r[2].tell()
10240
IDL> help,q
Q STRING = ''

The blob was actually entirely read out, but the data did not come through the bridge. Note that the returned 'q' variable should not be a string, since the output of the read() method can be (and in this case is) an array of binary bytes including null byte.
Since I am very far from being a Python expert, I might have done a big mistake.
Does someone have the correct way or any solution ?
alx.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: issues appending roi from IDLanROI to IDLanROIGroup
Next Topic: Read ASCII line till semicolon

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:17:23 PDT 2025

Total time taken to generate the page: 0.00449 seconds