title: Python, mysql.connector Error: No Result Set to Fetch From; cgitb shows correct value being passed to function
body: <p>Allright this one's got me baffled so I decided to see if I could find a response on here, I've searched up and down and several stackoverflow questions and answers and nothing has seemed to work.  All I'm trying to do is a SELECT * FROM statement using mysql.connector and I keep getting a "No Result Set" error.  Here's the code:</p>
  
  <pre><code>def session_fetch(value1):
      cnx = mysql.connector.connect(user='xxx', password='xxx', 
      host='127.0.0.1', database='xxx') 
      cursor = cnx.cursor()
      query = ("SELECT * FROM sessionkeys "
               "WHERE clientName='%s';") % value1 
      cursor.execute(query)
      row = cursor.fetchall()
      results = len(cursor.fetchall())
      clientName, clientAddr, unLocker = row[1], row[2], row[3]
      cnx.commit()
      cursor.close()
      cnx.close()
  </code></pre>
  
  <p>The error from cgitb shows:
   C:\inetpub\wwwroot\flighttoolsbz\validator.py in session_fetch(value1='ericdsmith86')<br>
      162     cursor.execute(query)<br>
      163     row = cursor.fetchall()<br>
  =>  164     results = len(cursor.fetchall())<br>
      165     clientName, clientAddr, unLocker = row[1], row[2], row[3]<br>
      166     cnx.commit()<br></p>
  
  <p>InterfaceError: No result set to fetch from.<br> 
        args = (-1, 'No result set to fetch from.', None)<br> 
        errno = -1 <br>
        msg = 'No result set to fetch from.' <br>
        sqlstate = None <br>
        with_traceback = built-in method with_traceback of InterfaceError object<br></p>
  
  <p>But when I go through the MySQL workbench and run the same query using the same input value, it returns the one row i'm looking for, so it's definitely there.  The only thing I can think of is that the %s formatter isn't taking what's being passed to the function as 'value1'.  What am I missing? </p>