Menu

Invalid literal for float()

Help
Anonymous
2003-05-19
2012-09-19
  • Anonymous

    Anonymous - 2003-05-19

    I'm having trouble with MySQL-python being unable to handle string rows.  Whenever a command attempts to execute and returns a string value in a column, it throws a ValueError exception: "invalid literal for float()" (ie, it looks like it's trying to turn everything into a float).

    import MySQLdb
    conn = MySQLdb.connect(db="database", user="user")
    c = conn.cursor()
    c.execute("SELECT * FROM table")

    Traceback (most recent call last):
      File "test.py", line 9, in ?
        c.execute("SELECT * FROM table")
      File "/usr/local/lib/python2.2/site-packages/MySQLdb/cursors.py", line 95, in execute
        return self._execute(query, args)
      File "/usr/local/lib/python2.2/site-packages/MySQLdb/cursors.py", line 114, in _execute
        self.errorhandler(self, exc, value)
      File "/usr/local/lib/python2.2/site-packages/MySQLdb/connections.py", line 33, in defaulterrorhandler
        raise errorclass, errorvalue
    ValueError: invalid literal for float(): A String

    Using the debugger, the actual source of the exception is in _fetch_row(), line 201, in cursors.py: return self._result.fetch_row(size, self._fetch_type) is throwing it.  Size and self._fetch_type are both 0 when it's called.

    I'm using Python 2.2.2, MySQL 4.0.12, and MySQL-python 0.9.2

    Any ideas?

     
    • Eddie Parker

      Eddie Parker - 2004-03-18

      I'm seeing this same thing. Was there any resolution on this problem?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.