Hi I'm following a tutorial online to build a flask web app and keeping coming across this error when I try to store information into my db via the sign up button.
from flask import Flask, render_template, json, request from flask.ext.mysqldb import MySQL from werkzeug import generate_password_hash, check_password_hash app = Flask(__name__) mysql = MySQL(app) # MySQL configurations app.config['MYSQL_DATABASE_USER'] = 'root' app.config['MYSQL_DATABASE_PASSWORD'] = 'pass' app.config['MYSQL_DATABASE_DB'] = 'table' app.config['MYSQL_DATABASE_HOST'] = 'localhost' mysql.init_app(app) @app.route("/") def main(): return render_template('index.html') @app.route('/showSignUp') def showSignUp(): return render_template('signup.html') @app.route('/signUp', methods = ['POST','GET' ]) def signUp(): _phonenumber = request.form['phonenumber'] _name = request.form['name'] _password = request.form['password'] if _phonenumber and _name and _password: conn = mysql.connect() cursor = conn.cursor() _hashed_password = generate_password_hash(_password) cursor.callproc('sp_createphoneuser', (_phonenumber,_name,_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>'}) if __name__ == "__main__": app.debug = True app.run(port=5002) So that is the code I have and everytime I try to register a user I get this error in terminal:
File "/home/john/FlaskApp/app.py", line 35, in signUp conn = mysql.connect() TypeError: 'Connection' object is not callable My theory is that there was a problem during installation but I'm not sure.