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('ImageResu lts.html', 'wb')
cPickle.dump(Ou tputHTML, HTMLoutputFile) # outputHTML is a standard
html page
HTMLoutputFile. close()
DBfilelistFile = open('DBFilesLi st.txt', 'wb')
cPickle.dump(DB filelist, DBfilelistFile) # DBfileList is a list of
filenames in the form ['XXX.jpg', 'XXX.jpg' etc]
DBfilelistFile. close()
DBURL = 'http://www.myhomepage. html'
blobdata = open('ImageResu lts.html', 'rb').read()
blobfiles = open('DBFilesLi st.txt', 'rb').read()
db = sqlite.connect( "ImageInfoDatab ase.db")
c = db.cursor()
try:
c.execute("crea te table FileURLInfo (URL CHAR(100), Images, HTML)")
except:
print 'database exists'
c.execute("INSE RT INTO FileURLInfo VALUES (?,?,?);", (DBURL,
sqlite.Binary(b lobfiles), sqlite.Binary(b lobdata)),)
c.execute("sele ct Images from FileURLInfo where URL =
'http://www.myhomepage. html'",)
DBImageResult = c.fetchall()
print DBImageResult
#script ends 1 1523 al*********@gma il.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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 columns). The
program scans an input file and inserts data into those three tables.
First I used pysqlite (ver 2). It took a few seconds to parse and
populate one thousand of main record and five-six thousand detail
records (including a print...
|
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);
|
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 avail.
Build and install appear to go smoothly but attempting to run the tests
from the python interpreter fails. Likewise any attempt to utilise
pysqlite2 in a python script fails.
|
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 c:\programme\python24\lib\site-packages\turbogears-1.0.1-
py2.4.egg
Processing dependencies for TurboGears>=1.0
|
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 error message is
longer than what I send here.
% easy_install pysqlite
Searching for pysqlite
Reading http://cheeseshop.python.org/pypi/pysqlite/
Reading http://pysqlite.org/
| |
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 = """create table t1(
ID INTEGER PRIMARY KEY,
data BLOB );"""
|
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 features.
Go to http://pysqlite.org/ for downloads, online documentation and
|
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 I get:
$ easy_install pysqlite
Searching for pysqlite
Reading http://pypi.python.org/simple/pysqlite/
Reading http://pysqlite.org/
Reading http://initd.org/pub/software/pysqlite/releases/2.3/2.3.3/
Reading http://pysqlite.sourceforge.net/
|
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 directory". So,
I assume that the absence of the "sqlite3.h" is the origin of the
problem.
I found on the web, that this file should be either in "/usr/local/
include" or in "/usr/local/lib". I check this directories and I really
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |