Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an Oracle wrapper for Python that supports xmltype columns?

It seems cx_Oracle doesn't.

Any other suggestion for handling xml with Oracle and Python is appreciated.

Thanks.

like image 618
friol Avatar asked Nov 05 '22 21:11

friol


2 Answers

I managed to do this with cx_Oracle.

I used the sys.xmltype.createxml() function in the statement that inserts the rows in a table with XMLTYPE fields; then I used prepare() and setinputsizes() to specify that the bind variables I used for XMLTYPE fields were of cx_Oracle.CLOB type.

like image 119
friol Avatar answered Nov 14 '22 21:11

friol


I managed to get this to work by wrapping the XMLElement call in a call to XMLType.GetClobVal():

For example:

select xmltype.getclobval(xmlelement("rowcount", count(1)))
from...

No idea of the limitations yet but it got me out of trouble. Found the relelvant info on Oracle site: Mastering Oracle+Python, Part 1: Querying Best Practices

like image 39
Vincent Kolosowski Avatar answered Nov 14 '22 23:11

Vincent Kolosowski