title: AttributeError: 'NoneType' object has no attribute 'fetchall'
body: <p>I tried to make a short statement function which will return to me result of query.
  This works perfectly with pyodbc but not with mysql connector.</p>
  <p>The output was :</p>
  <blockquote>
  <p>File &quot;/mySQLDB.py&quot;, line 17, in execute_and_fetch
  result = conn.cursor().execute(query, params).fetchall()
  AttributeError: 'NoneType' object has no attribute 'fetchall'</p>
  </blockquote>
  <pre><code>import mysql.connector
  
  class MYSQLDB:
      def __init__(self):
          self.host = 'xx'
          self.database = 'xx$xx'
          self.user = 'xx'
          self.password = 'xx'
  
      def execute(self, query, *params):
          mysql.connector.connect(host=self.host, database=self.database,
                           user=self.user, password=self.password).cursor().execute(query, params).commit()
  
      def execute_and_fetch(self, query, *params):
          conn = mysql.connector.connect(host=self.host, database=self.database,
                           user=self.user, password=self.password)
          result = conn.cursor().execute(query, params).fetchall()
          conn.commit()
          return result
  </code></pre>