diff --git a/src/Python/flask/web/app.py b/src/Python/flask/web/app.py index c9a37a1..2f606b7 100644 --- a/src/Python/flask/web/app.py +++ b/src/Python/flask/web/app.py @@ -1,6 +1,6 @@ from flask import Flask, request, render_template, jsonify import paho.mqtt.client as mqtt -from flask_mysqldb import MySQL +import mysql.connector app = Flask(__name__) @@ -18,13 +18,15 @@ mqtt_client.loop_start() mqtt_client.subscribe("kobuki/data") mqtt_client.on_message = on_message # this lines needs to be under the function definition otherwise it cant find which function it needs to use -app.config['MYSQL_HOST'] = 'localhost' -app.config["MYSQL_USER"] = 'admin' -app.config["MYSQL_PASSWORD"] = 'kobuki' -app.config["MYSQL_DB"] = 'kobuki' -mysql = MySQL(app) +cnx = mysql.connector.connect( + host="127.0.0.1", + port=3306, + user="admin", + password="kobuki!", + database="kobuki") +cnx.close() @app.route('/') def index(): @@ -62,7 +64,7 @@ def phpmyadmin_passthrough(path): @app.route("/database") def database(): try: - cur = mysql.connection.cursor() + cur = cnx.cursor() cur.execute("SELECT * FROM kobuki_data") rows = cur.fetchall() # Haal alle rijen op uit het resultaat cur.close()