【发布时间】:2023-03-06 18:26:01
【问题描述】:
我有一个带有 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 列重新创建一个新表。但我买不起,因为我已经有大量这种格式的数据......
有什么想法吗?
【问题讨论】:
-
我很好奇——为什么是
cursor.setoutputsize(1200000000)?我发现您的链接代码有所不同。 -
它没有使用默认值,所以我尝试增加它...
-
您是否考虑过使用
dbms_lob即时转换为blob?