0

I am querying a Oracle database and need some special handling around one column of data that is a clob. I can read in the clobe with .read(). I'd like to write the actual value back to my array. It's a tuple so I must convert to a list, write the value, then convert back to tuple. I am getting the error message: TypeError: 'tuple' object does not support item assignment

My Code:

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
3
  • Please remember that Python uses 0-based indexing! Commented Aug 21, 2014 at 5:24
  • @bernie are you saying my for loop should start at 0? Commented Aug 21, 2014 at 5:26
  • @bernie can you elaborate on what you mean about storing data structures? Commented Aug 21, 2014 at 5:30

1 Answer 1

1

Try this way

for currentrow in data : 
     description= currentrow[1].read()
     tupled_data= tuple([currentrow[0],description])


print tupled_data
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.