Fetching file from db and save it into local folder using python

為{幸葍}努か 提交于 2019-12-11 18:39:17

问题


I am trying to retrieve data from database and save it into excel/csv file, There is column containing blob data , i have to save that data in .zip format in a local folder with name of that file (i.e., the name of the file containing that blob data, which is already a column value in my database). I have written the below code to store all the non blob column in my excel but i am not able to fetch that blob column from db and save it into the folder. Please suggest.

import os
import cx_Oracle
import csv

SQL="SELECT * FROM SOME_TABLE"


filename="S:\Output.csv"
FILE=open(filename,"w");
output=csv.writer(FILE, dialect='excel')



connection = cx_Oracle.connect('userid/password@99.999.9.99:PORT/SID')

cursor = connection.cursor()
cursor.execute(SQL)
for row in cursor:
    output.writerow(row)
cursor.close()
connection.close()
FILE.close()

Thanks, Aditya Singh

来源:https://stackoverflow.com/questions/58841272/fetching-file-from-db-and-save-it-into-local-folder-using-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!