python – cx_oracle如何更新blob列
发布时间:2020-12-20 11:38:58 所属栏目:Python 来源:网络整理
导读:任何人都可以帮助如何更新oracle中的blob数据 所以,我想尝试: file = open ('picture.jpg','rb') ext = 'jpg'content = file.read ()file.close ()db = cx_Oracle.connect('user','pwd',dsn_tns)db=db.cursor()sqlStr = "update table_name set column1=:bl
任何人都可以帮助如何更新oracle中的blob数据
所以,我想尝试: file = open ('picture.jpg','rb') ext = 'jpg' content = file.read () file.close () db = cx_Oracle.connect('user','pwd',dsn_tns) db=db.cursor() sqlStr = "update table_name set column1=:blobData,column2=" + str(ext) + " where id = 1" db.setinputsizes (blobData = cx_Oracle.BLOB) db.execute (sqlStr,{'blobData': content}) db.execute ('commit') db.close() 最后,我收到了这样的错误: cx_Oracle.DatabaseError: ORA-00904: "JPG": invalid identifier 解决方法file = open ('picture.jpg',dsn_tns) db=db.cursor() blobvar = db.var(cx_Oracle.BLOB) blobvar.setvalue(0,content) sqlStr = "update table_name set column1=:blobData,column2="jpg" where id = 1" db.setinputsizes (blobData = cx_Oracle.BLOB) db.execute (sqlStr,{'blobData': blobvar}) db.execute ('commit') db.close() (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |