我正在尝试学习flask-mysql using this link 但我得到某种类型的错误
from flask import Flask
from flaskext.mysql import MySQL
app = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_DATABASE_USER'] = 'root'
app.config['MYSQL_DATABASEE_PASSWORD'] = 'root'
app.config['MYSQL_DATABASE_DB'] = 'EmpData'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)
@app.route('/')
def index():
return 'hello people'
@app.route("/Authenticate")
def Authenticate():
username = request.args.get('UserName')
password = request.args.get('Password')
cursor = mysql.get_db().cursor()
cursor.execute("SELECT * from User where Username='" + username + "' and Password='" + password + "'")
data = cursor.fetchone()
if data is None:
return "Username or Password is wrong"
else:
return "Logged in successfully"
if __name__ == "__main__":
app.run(debug = True)
帮我理解这个问题 在终端: mysql -u root -p ;密码:root
答案 0 :(得分:2)
错误在这里 - > app.config['MYSQL_DATABASEE_PASSWORD'] = 'root'
更正app.config['MYSQL_DATABASE_PASSWORD'] = 'root'
的密钥,即从E
删除额外的MYSQL_DATABASEE_PASSWORD
字符。