Python Flask-Mysql KeyError: ‘MYSQL_HOST’

I am building a python flask-Mysql app. I am building it using AWS cloud9. But When I run the code I am geting MYSQL_HOST key error. I am attaching code below. Is it because of the installation fault or code error.?`

from flask import Flask, request, render_template
from flask_mysqldb import MySQL

application = Flask(__name__)

application.config['MYSQL_HOST'] = 'localhost'
application.config['MYSQL_USER'] = 'nfhfjfn'
application.config['MYSQL_PASSWORD'] = 'fsfc'
application.config['MYSQL_DB'] = 'fsvf'
application.config['MYSQL_CURSORCLASS'] = 'DictCursor'
mysql = MySQL(application)
# mysql.init_app(application)

application = Flask(__name__)

def hello():
    cursor = mysql.connect().cursor()
    cursor.execute("SELECT * from LANGUAGES;")
    languages = cursor.fetchall()
    languages = [list(l) for l in languages]
    return render_template('index.html', languages=languages)
if __name__ == "__main__":'',port=8080, debug=True)


Read more here:

Content Attribution

This content was originally published by Namshad_muhammed at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: