469,609 Members | 1,178 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

blob problems in pysqlite

Hi there.

I'm a long-time lurker and (I think) first time poster.
Only relatively new to python, and I'm trying to get pysqlite to work
with binary data, and having a tough time of it.
I want to set up a table with:
- a URL,
- some filenames related to that URL,
- and some simple generated HTML.

Problem is, when I try to do this, and query, say, the filenames from
the filename field 'Images', I'm not getting a result. Just []...
I've been googling this one for days (documentation for this seems
really scant), and I've tried a whole bunch of things, but my code as
it is now is attached.

Can anyone give me some idea what i'm doing wrong (or if this is indeed
possible)?
Any and all help much appreciated.

Cheers, Al.

#script starts

from pysqlite2 import dbapi2 as sqlite

HTMLoutputFile = open('ImageResults.html', 'wb')
cPickle.dump(OutputHTML, HTMLoutputFile) # outputHTML is a standard
html page
HTMLoutputFile.close()
DBfilelistFile = open('DBFilesList.txt', 'wb')
cPickle.dump(DBfilelist, DBfilelistFile) # DBfileList is a list of
filenames in the form ['XXX.jpg', 'XXX.jpg' etc]
DBfilelistFile.close()

DBURL = 'http://www.myhomepage.html'
blobdata = open('ImageResults.html', 'rb').read()
blobfiles = open('DBFilesList.txt', 'rb').read()

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

c = db.cursor()

try:
c.execute("create table FileURLInfo (URL CHAR(100), Images, HTML)")
except:
print 'database exists'

c.execute("INSERT INTO FileURLInfo VALUES (?,?,?);", (DBURL,
sqlite.Binary(blobfiles), sqlite.Binary(blobdata)),)
c.execute("select Images from FileURLInfo where URL =
'http://www.myhomepage.html'",)

DBImageResult = c.fetchall()
print DBImageResult

#script ends

Apr 26 '06 #1
1 1410
al*********@gmail.com wrote:
Hi there.

I'm a long-time lurker and (I think) first time poster.
Only relatively new to python, and I'm trying to get pysqlite to work
with binary data, and having a tough time of it. [...]


It seems to me that you're using pysqlite correctly. Where exactly is
the problem? Is the fetchall() not delivering what you think it should?
If so, please explain what exactly it yields, and what you expect it to
yield.

-- Gerhard
Apr 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by qvx | last post: by
11 posts views Thread by CSN | last post: by
6 posts views Thread by Rob Cowie | last post: by
14 posts views Thread by Nader Emami | last post: by
3 posts views Thread by rustyhowell | last post: by
5 posts views Thread by =?ISO-8859-1?Q?Gerhard_H=E4ring?= | last post: by
4 posts views Thread by Tilman Kispersky | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.