[Tutor] Read only buffer tuple ?

Bob Gailer bgailer@alum.rpi.edu
Thu May 22 22:46:02 2003


At 06:55 PM 5/22/2003 +0000, james dean wrote:


>Hi all, I have a file writing problem.
>
>I am extracting some text from a database and opening a file to write it 
>to and I get this error.
>
>f.write(msg[0])
>TypeError: read-only buffer, tuple
>
>Here is the code I am using:
>
>sql = "SELECT message FROM email WHERE emailid='%s'" % (rows[0])
>msg = con1.query(sql).getresult()
>f = open('temp','w')
>f.write(msg[0])
>f.close
>
>What am I doing wrong?

Please show us what msg[0] looks like. Is it a string? Most data base 
queries are returned as a sequence of rows, and each row is a sequence.

Bob Gailer
bgailer@alum.rpi.edu
303 442 2625