title: AttributeError when initializing Flask app - 'MySQL' object has no attribute 'connection'
body: <p>I'm trying to run a flask app together with a MySQL server. But I can't seem to get pass the connect-to-db stage. My <code>app.py</code> has the following code:</p>
  
  <pre><code>from flask import Flask, render_template
  from flaskext.mysql import MySQL
  
  app = Flask(__name__)
  mysql = MySQL()
  
  app.config['MYSQL_DATABASE_HOST '] = 'localhost'
  app.config['MYSQL_DATABASE_USER'] = 'root'
  app.config['MYSQL_DATABASE_PASSWORD'] = 'mypassword'
  app.config['MYSQL_DATABASE_DB'] = 'users'
  app.config['MYSQL_CURSORCLASS'] = 'DictCursor'
  mysql.init_app(app)
  cur = mysql.connection.cursor()
  
  @app.route('/')
  def index():
      return render_template('layout.html')
  
  if __name__ == '__main__':
      app.run(debug=True)
  </code></pre>
  
  <p>When I run this script in <code>Git Bash</code>, I get:</p>
  
  <pre><code>$ python app.py
  Traceback (most recent call last):
    File "app.py", line 13, in &lt;module&gt;
      cur = mysql.connection.cursor()
  AttributeError: 'MySQL' object has no attribute 'connection'
  </code></pre>
  
  <p>I do not see any issue with the <code>app.py</code> script above. The <code>MySQL</code> module is imported, initialized and it still does not run. Can someone please offer some suggestions of what could possibly be the problem?</p>