Archive of June 2010

Tue 29 Jun

python-mysqldb: execute() first

While working on implementing a schema-free, MySQL-backed data store (thanks, Bret Taylor!), I ran into a problem with using MySQLdb to access the database. I'll eventually post the code I wrote up on this site so others can see my example, but for now the following will suffice. When performing a SELECT, I would get the following error upon attempting to fetch my results.

Incorrect Python:
q = "SELECT body FROM entities WHERE id='%s'" % (entity_id)
entity = self.conn.cursor().fetchone()

File "", line 93, in get
entity = self.conn.cursor().fetchone()
File "/usr/lib/pymodules/python2.6/MySQLdb/", line 340, in fetchone
File "/usr/lib/pymodules/python2.6/MySQLdb/", line 70, in _check_executed
self.errorhandler(self, ProgrammingError, "execute() first")
File "/usr/lib/pymodules/python2.6/MySQLdb/", line 35, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: execute() first

The issue was using two separate cursor objects. Here's the corrected code:
c = self.conn.cursor()
q = "SELECT body FROM entities WHERE id='%s'" % (entity_id)
entity = c.fetchone()

Wed 23 Jun

ERROR: please fix package in OpenWRT

I'm putting together an OpenWRT package for a project I'm working on and ran into a perplexing error message as I was testing my new package's Makefile:

[[email protected] backfire]$ make menuconfig

ERROR: please fix package/click/Makefile

To get a more descriptive error message, enter the following from the root directory of your OpenWRT source distribution:

TOPDIR=$PWD make -C package/ DUMP=1

Doing this let me discover that I was using a deprecated description tag inside my Makefile.