title: Python MySQLdb empty select query although manual query execution delivers results
body: <p>I have written a python daemon that continuously polls a mysql database. It works fine when I continuously connect and reconnect to the database between queries as follows:</p>
  
  <pre><code>def connect(self):
      self.connection = MySQLdb.connect(...)  
      self.cursor = self.connection.cursor()  
      return self.cursor
  
  def disconnect(self): ...
      self.cursor.close()
      self.connection.close()
  
  def getData(); ....
     sqlcmd = """SELECT ...."""
     self.cursor.execute (sqlcmd % (params))
     result =  self.cursor.fetchall()
     return result
  
  if __name__ == "__main__":
      db = prepaid_db.Database()
      while 1:
          dbConnection = db.connect()
          data = db.getData()
          ... do stuff
          db.disconnect
  </code></pre>
  
  <p>But when I try to keep the database connection open (as below) I get an empty query, even though, while it is running I can query the db manually, give it the same query and get the result I expect.</p>
  
  <pre><code>if __name__ == "__main__":
      db = prepaid_db.Database()
      dbConnection = db.connect()
      while 1:
          data = db.getData()
          ... do stuff
      db.disconnect
  </code></pre>
  
  <p>I have tried everything to understand why it would do this: </p>
  
  <ul>
  <li>disabled query cache and added random x=x to the query in case mysql cache was confused by the similar queries</li>
  <li>enabled mysql query logging: the query comes through but still returns an empty set</li>
  <li>moved cursor.connect to database.connect, and back into getData(), no difference</li>
  </ul>
  
  <p>I would love a clue as to what I am not understanding.</p>