нашел такое решение, вопрос с условностью проверки наличия атрибута read
for row in cursor.fetchall():
count_rows+=1
result_inside={}
row_content=[]
for col, val in zip(col_names, row):
# проверяем наличие атрибута у объекта, если CLOB то приеняем read
if hasattr(val, 'read'):
result_inside[col] = val.read()
else:
result_inside[col] = val
row_content.append(result_inside[col])
json_file.write(json.dumps(result_inside, default = myconverter))
у решения выше есть проблема
Internally, Oracle uses LOB locators which are allocated based on the
cursor array size. Thus, it is important that the data in the LOB
object be manipulated before another internal fetch takes place. The
safest way to do this is to use the cursor as an iterator. In
particular, do not use the
fetchall() method.
поэтому
for row in cursor:
count_rows+=1
result_inside={}
row_content=[]
for col, val in zip(col_names, row):
# проверяем наличие атрибута у объекта, если CLOB то приеняем read
if hasattr(val, 'read'):
result_inside[col] = val.read()
else:
result_inside[col] = val
row_content.append(result_inside[col])
json_file.write(json.dumps(result_inside, default = myconverter))