我一直在尝试使用 Python 将 blob 数据从 oracle 获取到文本文件中。我在其他任何链接上都找不到答案。
下面是我的代码:
sql_string = """select
event_id
,blob_length
,blob field
from table"""
cur.execute(sql_string)
path = "P:/Folders/"
for row in cur:
filename = path + "notes_" + str(row[0]) + "_" + str(row[1]) + ".txt"
f = codecs.open(filename, encoding='utf-8', mode='wb+')
f.write(row[2])
f.close()
我收到以下错误
TypeError: utf_8_encode() argument 1 must be str, not cx_Oracle.LOB
我尝试了其他一些方法,但问题是即使是我见过的其他方法也只能处理字符串而不是 blob。