|
Richard Lewis
richardlewis at fastmail.co.uk
Wed Jan 10 12:28:14 EST 2007
Hi there,
I'm just trying to use SQLite with mod_python and I'm having a few problems.
I have a script which responds to the URL "/session" and does this:
from mod_python import apache
import sqlite, datetime
def handler(req):
# make query_dict from req.parsed_uri[apache.URI_QUERY]
# <snipped>
# load the sessions database
con = sqlite.connect("/abs/path/to/sessions.db")
cur = con.cursor()
# select the record for the session
cur.execute("SELECT * FROM sessions WHERE id=%s" %
query_dict["session-no"])
session = cur.fetchone()
if int(session[1]) == 0:
# this means that the session is not in use
# update the sessions database to set the session as 'in use'
cur.execute("UPDATE sessions SET in_use=1, name=\"%s\", started=\"%s\"
WHERE id=%d" % \
(query_dict["name"], str(datetime.datetime.now()),
int(query_dict["session-no"])))
con.commit()
# goes on to generate some HTML, etc.
The problem I have is that when I try to execute the SQL UPDATE query, the
database raises the exception "Database error: unable to open database file".
I've checked to make sure that I can execute the code correctly from the
Python interpreter, and I can.
So I also made sure that Apache has write permission to the database file by
setting the permissions to rwxrwxrwx!
Any ideas what may be wrong with this?
Cheers,
Richard
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Richard Lewis
Sonic Arts Research Archive
http://www.sara.uea.ac.uk/
JID: ironchicken at jabber.earth.li
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|