[mod_python] Dies on Database connection?

Ross M Karchner ross at karchner.com
Thu Jan 22 09:37:34 EST 2004


I am working on porting some scripts over to mod_python, but my scripts 
die when I attempt to execute a MySQL query.

Here is a demonstration of the problem: 

In mozilla, it loads a blank page, on Safari, I get a "page returned no 
data" error.

The code in display-rss.py is:
DB = "db"
USER = "user"
PASS = "password"

import MySQLdb

def index(req):
    DB_CONN = MySQLdb.connect(db=DB, user=USER, passwd=PASS)
    C.execute('select * from cities where id=17;')
    return "Something"

I have also tried using the code from : 

If I comment out the 'execute' statement, it works fine, the page that 
comes back displays the word "Something:", as expected.

I am using  Apache/2.0.48
Python 2.3.3
mod_python 3.0.4
on FreeBSD 4.9

My Apache configuration is:
AddHandler python-program .app
PythonHandler mod_python.publisher
PythonAutoReload On
PythonDebug On

I suspect this will be related to the Apache/FreeBSD threading can of 
worms... but I'm hoping there is another answer. If anyone has a spare 
clue to offer, I'd really appreciate it.



More information about the Mod_python mailing list