[mod_python] Dies on Database connection?

Michael C. Neel neel at mediapulse.com
Thu Jan 22 13:13:00 EST 2004


I don't see where you are fetching the data from the cursor, did you
snip that part?

Also, data is sent though req.write, you should return apache.OK or
other status as needed.

Are you new to mod_python and/or python?  IIRC there are some tutorials
on mp in the docs you may want to check out.

Mike


> -----Original Message-----
> From: Ross M Karchner [mailto:ross at karchner.com] 
> Sent: Thursday, January 22, 2004 9:38 AM
> To: mod_python
> Subject: [mod_python] Dies on Database connection?
> 
> 
> 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
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
> 



More information about the Mod_python mailing list