Python cx_读取lob时Oracle内存错误

Python cx_读取lob时Oracle内存错误,python,cx-oracle,Python,Cx Oracle,当尝试使用cx_或LCE从lob字段读取数据时,我收到“exceptions.MemoryError”。这段代码一直在工作,这个lob字段似乎太大了 Example: xml_cursor = ora_connection.cursor() xml_cursor.arraysize = 2000 try: xml_cursor.execute(“select xml_data from xmlTable where id = 1”) for row_data in xml_cur

当尝试使用cx_或LCE从lob字段读取数据时,我收到“exceptions.MemoryError”。这段代码一直在工作,这个lob字段似乎太大了

Example:
xml_cursor = ora_connection.cursor()
xml_cursor.arraysize = 2000
try:
    xml_cursor.execute(“select xml_data from xmlTable where id = 1”)
    for row_data in xml_cursor.fetchall():
        str_xml = str(row_data[0])  #this throws “exceptions.MemoryError”

是的,如果Python给MemoryError,这意味着一行中的一个字段占用的内存比您的要多(当然,LOB很有可能)。您必须将其切片并将其分块(使用
选择dbms_lob.substr(xml_数据,
重复)并将其馈送到增量xml解析器(或将其写入文件,或尝试使用该多GB lob执行的任何操作).
DBMS\u LOB
是Oracle提供的一个文档丰富的软件包,您可以在许多地方找到它的文档,例如