使用 cx_Oracle 读取 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
列的新表。但我买不起,因为我已经有千兆这种格式的数据......
知道吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建一个包含
BLOB
列的全局临时表,然后在获取LONG RAW
值之前使用TO_LOB
转换将其插入到该表中功能。然后您可以从临时表中选择BLOB
值。You can create a global temporary table with a
BLOB
column, and then just before getting theLONG RAW
value insert it into this table usingTO_LOB
conversion function. Then you can select theBLOB
value from the temporary table.