[Tutor] Mysql BLOB strangeness?

Brian Gustin brian at daviesinc.com
Sat Mar 18 21:14:23 CET 2006


Oh. just found the original question.. :)

OK perhaps this would be more helpful if you were to manually query 
mysql on command line and paste the results it outputs here.

what I am betting is your method to get the data out of teh query is 
doing exactly what you tell it to.. :)

but this hinges on the answer to "what is the original row of data 
returned by commandline mysql query"

keep in mind Mysql returns a result set as an array (a list or 
dictionary, when it is associative, if you will)

what your code is doing is taking the row (array) and appending it to an 
additional list..

and where you print the whole, you are basically printing out the 
multi-dimensional array, and I am betting the *last element* returned 
non-null in the mysql query is the content field.. :)

but again, it depends on what the actual content is..

run these two in mysql command line:

mysql> show create table report;
mysql> select * from report limit 1;

and let me know the results.. :)

I doubt that blob vs. text has anything to do with this issue :)

Bri!

Adam Cripps wrote:
> I'm trying to build a mini-CMS for my class to manage a single
> webpage, using CGI and mysql. The children will be storing their main
> content in a BLOB within a Mysql database.
> 
> When I query the content column, I get a strange return like this:
> 
> array('c', 'This is a test ')
> 
> - when the only text I entered in was 'This is a test'.
> 
> When I query mysql directly through a prompt, I get 'This is a test'.
> 
> Does a CGI query get mangled text from a blob? My other VARCHAR
> columns are fine.
> 
> Code:
> 
> def query(statement):
>     results = []
>     mycursor.execute(statement)
>     myrowcount = int(mycursor.rowcount)
>     for i in range (0, myrowcount):
>         myrow = mycursor.fetchone()
>         results.append(myrow)
>     return results
> 
> reportquery = "select id, title, content, published from report"
> reportlist = query(reportquery)
> print "<p>" + str(reportlist) + "</p>"
> 
> 
> id = primary key, integer, not null
> title = varchar(255)
> content = blob
> published = char(1), default ='n'
> 
> I've tried using looking at
> reportlist[0][2][1], but that just returns 'T' - which is obviously
> the T in 'This'.
> 
> TIA
> Adam
> --
> http://www.monkeez.org
> PGP key: 0x7111B833
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> !DSPAM:441ac610153321413855301!
> 
> 


More information about the Tutor mailing list