I have this list:
['ThisText', <cx_Oracle.LOB object at 0x02FDC080>]
Lst[1] content :
This is a string but as clob
Im populating the list from this query result as such :
import cx_Oracle
dsn_tns = cx_Oracle.makedsn('mario.connex.ro', '1529', service_name='EAIUAT')
conn = cx_Oracle.connect(user=r'LOGGING_DB05', password='passw0rd', dsn=dsn_tns)
c = conn.cursor()
c.execute("select column1, column2 from DB_Table where column3 = '1234'")
lst = []
for i in c:
for j in i:
lst.append(j)
table structure is :
Column1 = varchar
Column2 = clob
Column3 = varchar
I want to convert the clob value from lst[1] to string
str = ''.join(lst[1])
Error received :
TypeError: can only join an iterable
Printed the lst[1] type :
print(type(lst[1]))
<class 'cx_Oracle.LOB'>
Is there a way to convert the cx_Oracle.LOB value to string?
There are four types of LOB (large object): BLOB - Binary Large Object, used for storing binary data. cx_Oracle uses the type cx_Oracle. DB_TYPE_BLOB . CLOB - Character Large Object, used for string strings in the database character set format.
cx_Oracle is a Python extension module that enables access to Oracle Database. It conforms to the Python database API 2.0 specification with a considerable number of additions and a couple of exclusions.
Solved : using cx.oracle.LOB.read() method to retrive LOB data.
str = ''.join(lst[3].read())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With