MySQLdb: ValueError Something Stupid

mcl mcl.office at googlemail.com
Fri Sep 7 14:52:07 CEST 2007


On 7 Sep, 12:08, mcl <mcl.off... at googlemail.com> wrote:
> I have just started with python and MySQL.
>
> I have a simple test for each of my tables.
>
> The first two work as expected, but the third 'qlooks', gives a
> ValueError.
>
> If I copy and paste the SQL in the traceback to phpMyAdmin, it works
> as expected.
>
> Can anyone give a clue as to what I am doing wrong
>
> Python 2.4
> MySQL  4.1.22-standard
>
> The tablename qlooks is LOWERCASE
>
> Code =======================================================
>         cursor = gv.conn.cursor()
>         queries = ["%septi%"]
>         fields = ("qlTitle", "qlSubTitle", "qlPostCode", "qlMap",
> "qlDetails")
>         tblFields = "select * from qlooks "
>         whereTests = 'Where qlTitle like "%septi%"'
>         sql = tblFields + whereTests
>         #cursor.execute(sql)
>         cursor.execute('select * from PERMS')
>         row = cursor.fetchone()
>         print "Row=", row, gv.nl
>         cursor.execute('select * from LISTS')
>         row = cursor.fetchone()
>         print "Row=", row, gv.nl
>         cursor.execute('select * from qlooks')
>         row = cursor.fetchone()
>         print "Row=", row, gv.nl
>
>         cursor.close()
>
> ERROR TRACEBACK ++++++++++++++++++++++++++++++++++++++++
>
>    79         print "Row=", row, gv.nl
>    80         cursor.execute('select * from qlooks')
>    81         row = cursor.fetchone()
>    82         print "Row=", row, gv.nl
> cursor = <MySQLdb.cursors.Cursor instance>, cursor.execute = <bound
> method Cursor.execute of <MySQLdb.cursors.Cursor instance>>
>  /usr/lib/python2.4/site-packages/MySQLdb/cursors.py in
> execute(self=<MySQLdb.cursors.Cursor instance>, query='select * from
> qlooks', args=None)
>    93         """
>    94         del self.messages[:]
>    95         return self._execute(query, args)
>    96
>    97     def _execute(self, query, args):
> self = <MySQLdb.cursors.Cursor instance>, self._execute = <bound
> method Cursor._execute of <MySQLdb.cursors.Cursor instance>>, query =
> 'select * from qlooks', args = None
>  /usr/lib/python2.4/site-packages/MySQLdb/cursors.py in
> _execute(self=<MySQLdb.cursors.Cursor instance>, query='select * from
> qlooks', args=None)
>   112             exc, value, tb = exc_info()
>   113             del tb
>   114             self.errorhandler(self, exc, value)
>   115         self._executed = query
>   116         return r
> self = <MySQLdb.cursors.Cursor instance>, self.errorhandler = <bound
> method Connection.defaulterrorhandler of ...l.connection open to
> 'db.sabren.com' at 936cac4>>, exc = <class exceptions.ValueError>,
> value = <exceptions.ValueError instance>
>  /usr/lib/python2.4/site-packages/MySQLdb/connections.py in
> defaulterrorhandler(connection=<_mysql.connection open to
> 'db.sabren.com' at 936cac4>, cursor=<MySQLdb.cursors.Cursor instance>,
> errorclass=<class exceptions.ValueError>,
> errorvalue=<exceptions.ValueError instance>)
>    31     else:
>    32         connection.messages.append(error)
>    33     raise errorclass, errorvalue
>    34
>    35
> errorclass = <class exceptions.ValueError>, errorvalue =
> <exceptions.ValueError instance>
>
> ValueError: invalid literal for int(): 0-
>       args = ('invalid literal for int(): 0-',)
>
> =========================================
> Thanks Richard

Sort of solved it.

On that particular table it did not like * for all fields.

Any reason why that would be the case ?

Richard




More information about the Python-list mailing list