2

我有一个带有 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列的新表。但我买不起,因为我已经拥有这种格式的大量数据......

任何想法?

4

1 回答 1

0

您可以创建一个带有BLOB列的全局临时表,然后在获取值之前使用转换函数LONG RAW将其插入到该表中。TO_LOB然后您可以BLOB从临时表中选择值。

于 2018-02-08T10:56:39.190 回答