oracle9i数据库,python2.5,cx_Oracle-4[1].3.1-win32-9i-py25
#-*- coding:utf-8 -*-
import sys
import cx_Oracle
file = open(sys.argv[1], 'rb')
content = file.read()
file.close()
#Update BOLB
con = cx_Oracle.connect(“user”, “pass”, “TNS”)
cursor = con.cursor()
sql_update = "update t_soc_script t set t.content = :blobData where t.scripttype = 13"
cursor.setinputsizes(blobData=cx_Oracle.BLOB)
cursor.execute(sql_update, {'blobData':content})
cursor.execute('commit')
#read BLOB
sql_read = 'select t.scriptid,t.standsystemid,t.content from t_soc_script t where t.scripttype = 13 and rownum = 1'
num = 1
while (num):
cursor.execute(sql_read)
rs = cursor.fetchone()
if rs == None:
break
file = open('test_write.txt', "wb")
file.write(rs[2].read())
file.close()
num=num-1
cursor.close()
con.close()
参考:http://xufive.blog.163.com/blog/static/172326168201152992632106/