wtorek, 25 września 2012

DatabaseError: Invalid handle! while reading LOB in Python/cx_Oracle


I've spend much time on this:


orcl = cx_Oracle.connect(usrpass+'@'+dbase)
c = orcl.cursor()
c.execute(sq)
dane =  c.fetchall()

orcl.close() # before reading LOB to str

wkt = dane[0][0].read()

And I get: DatabaseError: Invalid handle!

But the following code works, because connection is closed after reading LOB to STR:
 
orcl = cx_Oracle.connect(usrpass+'@'+dbase)
c = orcl.cursor()
c.execute(sq)
dane =  c.fetchall()

wkt = dane[0][0].read()

orcl.close() # after reading LOB to str

[http://stackoverflow.com/questions/8646968/how-do-i-read-cx-oracle-lob-data-in-python/12590977#12590977]