title: Python mysql.connector - cursor.execute("WHERE .... ) returns NoneType
body: <p>I wanna code a login page using flask, but the value of the users that I get out of my database always is a NoneType. Even if the username that's entered in the login form is the same as the one in the database. I think I might have an error in the SQL Query but I can't figure Out where it is. I appreciate your help!</p>
  
  <p>Here's the login function with the line that should return how many rows have been found in the database.</p>
  
  <pre><code>@app.route("/login", methods=["GET", "POST"])
  def login():
      if request.method == "POST":
          #get form fields
          username = request.form["username"]
          password_candidate = request.form["password"]
  
          result = sqlhandler.mycursor.execute("SELECT * FROM users WHERE username = %s", [username])
          print(result) #result is a NoneType
  </code></pre>
  
  <p>here's the class of the sqlhandler:</p>
  
  <pre><code>class mySQLHandler():
      def __init__(self):
          self.db = mysql.connector.connect(
              host="localhost",
              user="root",
              passwd="notrealpassword ;)",
              db="testdb"
          )
  
          self.mycursor = self.db.cursor()
  </code></pre>
  
  <p>I'd really appreciate it, if anyone could tell me, why the execute statement returns a NoneType. I've already checked if the code in the mycursor.execute() works in the MySQL workbench and it does.</p>
  
  <p>Thank you!</p>