我有一个包含 LONG RAW 列的遗留数据库。此列中存储的数据约为 100KB。 我正在尝试使用 cx_Oracle 访问这些二进制数据。
它正在工作,但是我可以提取的最大大小是 ~41KB!
这是我的代码(来自 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
输出是这样的:
$ 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
我知道 LONG RAW
不容易处理。一些方法告诉我们用 BLOB
列重新创建一个新表。但我负担不起,因为我已经有数以千计的这种格式的数据...
有什么想法吗?
最佳答案
您可以使用 BLOB
创建一个全局临时表列,然后就在获得 LONG RAW
之前使用 TO_LOB
将值插入此表中转换功能。然后你可以选择BLOB
来自临时表的值。
关于python - 使用 cx_Oracle 读取 LONG RAW,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4746726/