【问题标题】:Read LONG RAW with cx_Oracle使用 cx_Oracle 读取 LONG RAW
【发布时间】: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

标签: python cx-oracle


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2011-07-26
    • 2012-08-21
    • 1970-01-01
    • 1970-01-01
    • 2018-05-13
    • 1970-01-01
    • 2018-01-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多