I am a beginner at python ,I have been trying to connect to SQL since days using Flask ,no virtual environment
This is the error I am getting
{"error": "(1044, \"Access denied for user 'ANU95'@'%' to database 'BucketList'\")"}
My app.py file
from flask import Flask ,render_template, request,json
from werkzeug import generate_password_hash, check_password_hash
from flaskext.mysql import MySQL
app = Flask(__name__)
app.config["DEBUG"] = True
mysql = MySQL()
# MySQL configurations
app.config['MYSQL_DATABASE_USER'] = 'ANU95'
app.config['MYSQL_DATABASE_PASSWORD'] = 'Anuradha'
app.config['MYSQL_DATABASE_DB'] = 'BucketList'
app.config['MYSQL_DATABASE_HOST'] = 'ANU95.mysql.pythonanywhere-services.com'
mysql.init_app(app)
@app.route('/')
def hello_world():
# # wait a long time for the Mysql connection to timeout
# cur = db.query(sql)
return render_template('index.html')
@app.route('/showSignUp')
def showSignUp():
return render_template('signup.html')
@app.route('/signUp',methods=['POST','GET'])
def signUp():
try:
_name = request.form['inputName']
_email = request.form['inputEmail']
_password = request.form['inputPassword']
# validate the received values
if _name and _email and _password:
conn = mysql.connect()
cursor = conn.cursor()
_hashed_password = generate_password_hash(_password)
cursor.callproc('sp_createUser',(_name,_email,_hashed_password))
data = cursor.fetchall()
if len(data) is 0:
conn.commit()
return json.dumps({'message':'User created successfully !'})
else:
return json.dumps({'error':str(data[0])})
else:
return json.dumps({'html':'<span>Enter the required fields</span>'})
except Exception as e:
return json.dumps({'error':str(e)})