1
我从Oracle数据库获取数据。一些数据是clob格式(第8列),所以我必须遍历每一行并进行转换。我想追加每个被转换的行以再次形成原始表。该行给我的麻烦是Complete_data = [Complete_data, fixed_data]
作为循环的一部分将行附加到列表中
import cx_Oracle
# USE THIS CONNECTION STRING FOR PRODUCTION
production_username = ''
production_password = ''
con_string = '%s/%[email protected]' % (production_username, production_password)
con = cx_Oracle.connect(con_string)
cursor = con.cursor()
querystring = ("Select * from SalesDatabase")
cursor.execute(querystring)
data = cursor.fetchall()
#loop through and convert clobs to readable content
for currentrow in data:
Product = currentrow[8].read()
fixed_data = ([currentrow[0], currentrow[1], currentrow[2], currentrow[3], currentrow[4], currentrow[5], currentrow[6], currentrow[7], Product, currentrow[9]])
Complete_data = [Complete_data, fixed_data]
con.close()
print Complete_data
非常感谢。 – user2242044 2014-08-27 17:49:04