Blob data from Oracle to text file using python

前端 未结 3 1066
悲哀的现实
悲哀的现实 2021-01-22 10:58

I have been trying to get the blob data from oracle into a text file using Python. I couldn\'t find the answer on any of the other links.

Below is my code :



        
3条回答
  •  遇见更好的自我
    2021-01-22 10:59

    If your LOBs are small enough to fit in memory you'll get better performance if you fetch BLOBs as LONG_BINARY (and use LONG_STRING for CLOBs):

    def OutputTypeHandler(cursor, name, defaultType, size, precision, scale):
        if defaultType == cx_Oracle.CLOB:
            return cursor.var(cx_Oracle.LONG_STRING, arraysize = cursor.arraysize)
        if defaultType == cx_Oracle.BLOB:
            return cursor.var(cx_Oracle.LONG_BINARY, arraysize = cursor.arraysize)
    

    See the cx_Oracle example at https://github.com/oracle/python-cx_Oracle/blob/master/samples/ReturnLobsAsStrings.py

提交回复
热议问题