[mod_python] invalid literal for float solved addendum

tpc at csua.berkeley.edu tpc at csua.berkeley.edu
Mon Oct 27 14:14:58 EST 2003


hi Grisha and Andy, after consulting with my coworker I believe there is a
bug in how MySQLdb interacts with mod_python that you should know of.  He
suggested I try out the same script that was giving me problems  with
Python CGI, and it works just fine.  The only difference is the values in
the tuple get switched around, so the tuple that is returned is (title,
URL) but no more invalid literal for float, int or long errors.  The
critical piece of code in question involves an implementation in Python
of a MySQL SELECT statement of two fields from one table joined to another
table that works just fine from the command line, in MySQL shell, and in
Python CGI:

	sql = """SELECT title, url FROM URLs, URLs_WITH_MATCHES WHERE
URLs.id = URLs_WITH_MATCHES.url_id;"""
	cursor.execute(sql)

gives me:

<paste>
Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

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

  File "/usr/lib/python2.2/site-packages/mod_python/publisher.py", line
149, in handler
    module = apache.import_module(module_name, req.get_config(), [path])

  File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line 502,
in import_module
    module = imp.load_module(mname, f, p, d)

  File "/var/www/html/python/temp-invalidtest.py", line 51, in ?
    search(terms)

  File "/var/www/html/python/temp-invalidtest.py", line 47, in search
    results = getMP3SearchResults(terms)

  File "/var/www/html/python/temp-invalidtest.py", line 15, in
getMP3SearchResults
    results = getMatchingURLs(cursor)

  File "/var/www/html/python/temp-invalidtest.py", line 42, in
getMatchingURLs
    cursor.execute(sql)

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

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

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

ValueError: invalid literal for float(): <insert any mp3 title here>
</paste>



More information about the Mod_python mailing list