473,320 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1499
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: qvx | last post by:
I'm writing a small project and I decided to try pysqlite. The database consists of one master table with five columns and two detail tables with one and two columns each (not counting foreign key...
11
by: CSN | last post by:
Is it possible to iterate over an array in plpgsql? Something like: function insert_stuff (rel_ids int) .... foreach rel_ids as id insert into table (rel_id, val) values (id, 5);
6
by: Rob Cowie | last post by:
Hi all, I'm having difficulty installing pysqlite 2.1.3 on Mac OS X 10.4.4 There are some notes on the pysqlite wiki regarding modification of the setup.py script and I've followed them to no...
1
by: Thomas | last post by:
Hi there! Installing TurboGears out-of-the-box (egg-based) on Windows doesn't work because I can't compile the extensions needed for the required pysqlite (also egg- based): Installed...
14
by: Nader Emami | last post by:
I have installed "TurboGears" and I would install 'pysqlite' also. I am a user on a Linux machine. If I try to install the 'pysqlite' with 'easy_install' tool I get the next error message. The...
3
by: rustyhowell | last post by:
I'm trying to store binary data in a sqlite database and call into the db using pysqlite 3. What I've got so far is this: import sqlite con = sqlite.connect(DB_PATH) cur = con.cursor() query...
5
by: =?ISO-8859-1?Q?Gerhard_H=E4ring?= | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 pysqlite 2.5.0 released ======================= I'm pleased to announce the availability of pysqlite 2.5.0. This is a release with major new...
4
by: Tilman Kispersky | last post by:
I am trying to install sqlite for use with python on cygwin. I have installed the sqlite packages from cygwin (that is libsqlite3-devel and libsqlite3_0). When attempting to easy_install pysqlite...
15
by: Kurda Yon | last post by:
Hi, I try to "build" and "install" pysqlite? After I type "python setup.py build" I get a lot of error messages? The first error is "src/ connection.h:33:21: error: sqlite3.h: No such file or...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.