blob problems in pysqlite

aldonnelley at gmail.com aldonnelley at gmail.com
Thu Apr 27 02:41:58 EDT 2006


Excellent. Got that working. Now, how to get the pickled data out of
the database?

I'm trying to use cPickle.loads(data) (code attached), and I get a:
"TypeError: loads() argument 1 must be string, not list"

Is there a workaround for this? I've tried converting the List of files
to a String before cPickling it, but the same result (expected). I've
read, in a post of Gerhard's somewhere, about marshal, but I don't see
how this would work for the HTML. (where I have the same problem.)

Cheers, Al.
ps. Tim: Your clean take on my code made me realise that I had stupidly
included quotes in the URL argument passed to sqlite,  ie I'd ended up
with, effectively, DBURL= '"http://www.myhomepage.com"', rather than =
'http://www.myhomepage.com'. It's the little things that matter...
Thanks for your help. Oh, and your 'representative samples' are spot
on!

#code starts
URL = "http://www.myhomepage.com"

db = sqlite.connect("ImageInfoDatabase.db")

c = db.cursor()

DBURL = str(URL)
print DBURL
c.execute("select Images from FileURLInfo where URL= ?;", (DBURL,))
KnownFilesResult = c.fetchall()
print KnownFilesResult    #where I get a r/w buffer, as expected
cPickle.loads(KnownFilesResult)    #where I get the error described
above.

#code ends.




More information about the Python-list mailing list