我正在查询Oracle数据库,需要对一列数据进行特殊处理。我可以用.read()
阅读clobe。我想把实际值写回我的数组。它是一个元组,所以我必须转换为列表,写入值,然后转换回元组。我收到错误消息:TypeError: 'tuple' object does not support item assignment
我的代码:
import cx_Oracle
# USE THIS CONNECTION STRING FOR PRODUCTION
production_username = 'username'
production_password = 'password'
con_string = '%s/%s@hostname:port/orcl' % (production_username, production_password)
con = cx_Oracle.connect(con_string)
cursor = con.cursor()
querystring = ("Select ID, Description from Table")
cursor.execute(querystring)
data = cursor.fetchall()
for currentrow in range(1, len(data)):
description= data[currentrow][1].read()
data = list(data)
data[currentrow][1] = description
data = tuple(data)
con.close()
print data
答案 0 :(得分:1)
试试这种方式
for currentrow in data :
description= currentrow[1].read()
tupled_data= tuple([currentrow[0],description])
print tupled_data