[mod_python] Dies on Database connection?

Ross Karchner ross at karchner.com
Thu Jan 22 20:12:44 EST 2004


On Jan 22, 2004, at 5:46 PM, Petros Keshishian wrote:
> Try to see whether your script works when you query
> only one column. I am very intersted in the solution
> of this problem.

YES! Thank you-

This is the same behavior.  If I change the query to only select one 
field, it works fine.

If it's a number...

As if things couldn't get stranger...

This works fine: C.execute('select id from cities where id=17;')
(id is an integer)
But this:
C.execute('select place from cities where id=17;')
(place is a string)
Throws:
Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

   File "/usr/local/lib/python2.3/site-packages/mod_python/apache.py", 
line 332, in HandlerDispatch
     result = object(req)

   File 
"/usr/local/lib/python2.3/site-packages/mod_python/publisher.py", line 
198, in handler
     result = apply(object, (), args)

   File "/usr/home/localfeeds/htdocs/near/display-rss.py", line 19, in 
index
     C.execute('select place from cities where id=17;')

   File "/usr/local/lib/python2.3/site-packages/MySQLdb/cursors.py", 
line 95, in execute
     return self._execute(query, args)

   File "/usr/local/lib/python2.3/site-packages/MySQLdb/cursors.py", 
line 114, in _execute
     self.errorhandler(self, exc, value)

   File "/usr/local/lib/python2.3/site-packages/MySQLdb/connections.py", 
line 33, in defaulterrorhandler
     raise errorclass, errorvalue

ValueError: invalid literal for float(): New York

What on earth could be trying to mangle the results of the query into a 
float? The traceback makes it pretty clear that this error happens when 
the query is executed.

The rest of Localfeeds.com  does a similar query thousands of times a 
day from Python CGI scripts. Same Python, same MySQLdb module, same 
everything.

Right now, I am going to see if I have better luck with the Apache and 
mod_python from the FreeBSD ports system

-Ross




More information about the Mod_python mailing list