python - 使用 cx_Oracle 读取 LONG RAW

标签 python 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 列重新创建一个新表。但我负担不起,因为我已经有数以千计的这种格式的数据...

有什么想法吗?

最佳答案

您可以使用 BLOB 创建一个全局临时表列,然后就在获得 LONG RAW 之前使用 TO_LOB 将值插入此表中转换功能。然后你可以选择BLOB来自临时表的值。

关于python - 使用 cx_Oracle 读取 LONG RAW,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4746726/

相关文章:

python - Selenium Firefox webdriver,使用 Python,在 div 中滚动

python - 远程 ipython 内核不显示图

python - 在 tomcat 上的 jython 下运行 cx_Oracle

python cx_oracle cursor.rowcount 返回 0 但 cursor.fetchall 返回数据

python - 在 Oracle DB 上从 python 运行 set role 命令

python - AttributeError : 'NoneType' object has no attribute 'to_capabilities' . 在 Appium 上运行 python 脚本时出现此错误

python - 如何从 url 下载文件并使用 python 请求保留其名称和元数据

python - 如何在 scikit-learn (sklearn) 的 Pipeline 中应用 StandardScaler?

python - 使用python和cx_oracle读写Clob数据

python - 使用 cx_Oracle 将变量绑定(bind)到表名