[mod_python] Dies on Database connection?

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


Hello,

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: 
http://localfeeds.com/near/display-rss.app

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=DB_CONN.cursor()
    C.execute('select * from cities where id=17;')
    return "Something"
-------------------------------

I have also tried using the code from : 
http://www.modpython.org/FAQ/faqw.py?req=all#3.3

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.

Thanks!,

-Ross


More information about the Mod_python mailing list