How to read a cx_Oracle.OBJECT with type cx_Oracle

2019-08-31 06:44发布

问题:

I'm trying read the content of a XMLType column from Oracle with cx_Oracle but i don't get it.

>>> row
(318, 379, 1, <cx_Oracle.OBJECT object at 0xef21ea0>)
>>> col = row[3]
>>> print col
<cx_Oracle.OBJECT object at 0xef21ea0>
>>> print col.type
<cx_Oracle.ObjectType SYS.XMLTYPE>

How can I read the content of a cx_Oracle.OBJECT with type cx_Oracle.ObjectType SYS.XMLTYPE?

回答1:

As said in Ivan's comment, a solution is compile a cx_Oracle with libxml.a. As workaround, I used the solution proposed in the following page and read all the content as XML.

http://www.oracle.com/technetwork/articles/dsl/mastering-oracle-python-xml-1391344.html