我正在使用cx_Oracle訪問 mon Oracle 資料庫 我一直在尋找一種從我的資料庫中提取檔案的方法,但我找不到解決方案。通過提取我的意思是下載。這是我到目前為止所得到的:
from types import prepare_class
from typing import overload
import cx_Oracle
dsn_tns = cx_Oracle.makedsn('****', '****', service_name='****')
conn = cx_Oracle.connect(user=r'****', password='****', dsn=****)
c = conn.cursor()
c.execute('my request')
for row in c:
print (row[0], '-', row[1])
conn.close()
我不知道我是否需要使用外部庫或直接請求。
uj5u.com熱心網友回復:
如果您有一個帶有名稱的列和一個帶有檔案內容的列,您可以執行以下操作:
for fileName,fileContents in c.execute('select fileName,file contents from the_table'):
with open(fileName, w) as f:
F.write(fileContents)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/361906.html
