mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
changed mysql package
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
from flask import Flask, request, render_template, jsonify
|
from flask import Flask, request, render_template, jsonify
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
from flask_mysqldb import MySQL
|
import mysql.connector
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@@ -18,13 +18,15 @@ mqtt_client.loop_start()
|
|||||||
mqtt_client.subscribe("kobuki/data")
|
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
|
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('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
@@ -62,7 +64,7 @@ def phpmyadmin_passthrough(path):
|
|||||||
@app.route("/database")
|
@app.route("/database")
|
||||||
def database():
|
def database():
|
||||||
try:
|
try:
|
||||||
cur = mysql.connection.cursor()
|
cur = cnx.cursor()
|
||||||
cur.execute("SELECT * FROM kobuki_data")
|
cur.execute("SELECT * FROM kobuki_data")
|
||||||
rows = cur.fetchall() # Haal alle rijen op uit het resultaat
|
rows = cur.fetchall() # Haal alle rijen op uit het resultaat
|
||||||
cur.close()
|
cur.close()
|
||||||
|
Reference in New Issue
Block a user