I'm working with Python and Flask for the first time. I'm trying to create a simple query select to my database and display the data.
from flask import Flask
from flaskext.mysql import MySQL
mysql = MySQL()
app = Flask(__name__)
app.config['MYSQL_DATABASE_USER'] = 'myuser'
app.config['MYSQL_DATABASE_PASSWORD'] = 'mypass'
app.config['MYSQL_DATABASE_DB'] = 'mydb'
app.config['MYSQL_DATABASE_HOST'] = 'my server'
mysql.init_app(app)
@app.route("/")
def hello():
cursor = mysql.connect().cursor()
cursor.execute("Select * From Users Where UserID = 215")
data = cursor.fetchone()
return data
if __name__ == "__main__":
app.run()
It is giving me the error: The view function did not return a valid response tuple.
Thanks