开发者

Read LONG RAW with cx_Oracle

I've a legacy database with LONG RAW columns. Data stored in this columns are about ~100KB. I'm trying to access those binary data with cx_Oracle.

It is working, however the maximum size I could extract is ~41KB !

Here's my code (from http://dbaportal.开发者_开发技巧eu/?q=node/147)

cursor = db.cursor()    
cursor.arraysize = 1
cursor.setoutputsize(1200000000)

cursor.execute("select data from mytable")
print cursor.description
for row in cursor:
    data = row[0]
    f = open("/tmp/data",'wb')
    f.write(data)
    f.close()
    # Only first line
    break

Output is like this:

$ python oracle.py
[('GRIB', <type 'cx_Oracle.LONG_BINARY'>, -1, 0, 0, 0, 1)]
$ ls -lh /tmp/data
41186 2011-01-20 12:42 /tmp/pygrib

I know LONG RAW are not easy to deal with. Some methods tell to recreate a new table with BLOB column. But I can't afford it because I've already gigas of data in this format...

Any idea?


You can create a global temporary table with a BLOB column, and then just before getting the LONG RAW value insert it into this table using TO_LOB conversion function. Then you can select the BLOB value from the temporary table.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜