[mod_python] Dies on Database connection?

Petros Keshishian pkeshishian at yahoo.com
Thu Jan 22 14:46:54 EST 2004


Ross:

I had the same problem in mod_python with MySQL:
Namely the script was working from python shell, but
not in mod_python. I discovered that when I query only
one column  , e.g. 
C.execute('select id from cities where id=17;')
than it worked in mod_python as well, but when I try
for more that one column it dies. Unfortunatly I could
not find a solution and since my database is very
small I wrote a script that queries the database for
each column separately and then combines and returns
the result. This is not really a solution because it
does not address the problem and can slow down your
program significantly if your database is large.

Try to see whether your script works when you query
only one column. I am very intersted in the solution
of this problem.

-Petros


= = = Original message = = =

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

___________________________________________________________
Sent by ePrompter, the premier email notification
software.
Free download at http://www.ePrompter.com.

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/


More information about the Mod_python mailing list