@transaction.atomic def fun(): insertSQL = """insert into my_blob (id, date_created, date_updated, filename, blob_data,blob_size) \ values (appstore_blob_sq.nextval, :1, :2, :3, :blobd,:5)""" self.cursor.execute(insertSQL,{'3':filename, '5' : filesize, 'blobd':blobd, '1' : dctime, '2' : dctime}) #retrieve blob_data from the row so that we can add chunks to the LOB self.cursor.execute("select blob_data from appstore_blob where filename = :file_name for update of blob_data", file_name=filename) for row in self.cursor: offset = 0 lob = row[0] writechunk_sz = lob.getchunksize() #compute the read chunk size factor = int(blob_writechunk_sz/writechunk_sz) if factor > 0: writechunk_sz *= factor lob.open() while True: chunk = filehandle.read(writechunk_sz) chk_len = len(chunk) #print "write chunk of sz: %s" % chk_len if chunk is None or chunk == "": break lob.write(chunk, offset+1) offset += chk_len lob.close() break