Merge branch 'main' of gitlab.fdmci.hva.nl:propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-3/qaajeeqiinii59
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
-- Wed Mar 13 16:04:58 2024
|
-- Wed Mar 13 16:04:58 2024
|
||||||
-- Model: New Model Version: 1.0
|
-- Model: New Model Version: 1.0
|
||||||
-- MySQL Workbench Forward Engineering
|
-- MySQL Workbench Forward Engineering
|
||||||
|
-- CHANGE NODEID TO AUTO INCREMENET IN NODE TABLE
|
||||||
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
||||||
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
||||||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
|
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
from flask import Flask, request
|
from flask import Flask, request, jsonify
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
from queries import *
|
from queries import *
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@@ -10,8 +10,15 @@ def index():
|
|||||||
MAC = request.args.get('MAC', default = None)
|
MAC = request.args.get('MAC', default = None)
|
||||||
return getData(node, dataType, MAC)
|
return getData(node, dataType, MAC)
|
||||||
|
|
||||||
def getData(node, dataType, MAC):
|
@app.route('/putData', methods=['PUT'])
|
||||||
try:
|
def putData():
|
||||||
|
node_id = request.json.get('node_id', None)
|
||||||
|
new_name = request.json.get('new_name', None)
|
||||||
|
new_location = request.json.get('new_location', None)
|
||||||
|
|
||||||
|
if node_id is None:
|
||||||
|
return jsonify({"error": "node_id is required"}), 400
|
||||||
|
|
||||||
mydb = mysql.connector.connect(
|
mydb = mysql.connector.connect(
|
||||||
host="localhost",
|
host="localhost",
|
||||||
user="root",
|
user="root",
|
||||||
@@ -19,18 +26,52 @@ def getData(node, dataType, MAC):
|
|||||||
database="NodeData"
|
database="NodeData"
|
||||||
)
|
)
|
||||||
|
|
||||||
query = get_query(node, dataType, MAC)
|
cursor = mydb.cursor()
|
||||||
cursor = mydb.cursor(dictionary=True) # Enable dictionary output
|
|
||||||
cursor.execute(query)
|
if new_name is not None:
|
||||||
result = cursor.fetchall() # Fetch the results
|
cursor.execute("UPDATE Node SET Name = %s WHERE NodeID = %s", (new_name, node_id))
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
|
if new_location is not None:
|
||||||
|
cursor.execute("UPDATE Node SET Location = %s WHERE NodeID = %s", (new_location, node_id))
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
mydb.close()
|
mydb.close()
|
||||||
|
|
||||||
|
return jsonify({"message": "Node updated successfully"}), 200
|
||||||
|
|
||||||
|
def putData(node, name, location, MAC):
|
||||||
|
mydb = loginDB()
|
||||||
|
query = get_query(node, name, location, MAC)
|
||||||
|
cursor = mydb.cursor(dictionary=True) # Enable dictionary output
|
||||||
|
cursor.execute(query)
|
||||||
|
result = cursor.fetchall() # Fetch the results
|
||||||
|
cursor.close()
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
except mysql.connector.Error as err:
|
|
||||||
print("MySQL Error:", err)
|
def loginDB():
|
||||||
return "MySQL Error: " + str(err)
|
mydb = mysql.connector.connect(
|
||||||
|
host="localhost",
|
||||||
|
user="root",
|
||||||
|
password="Dingleberries69!",
|
||||||
|
database="NodeData"
|
||||||
|
)
|
||||||
|
return mydb
|
||||||
|
|
||||||
|
def getData(node, dataType, MAC):
|
||||||
|
mydb = loginDB()
|
||||||
|
query = get_query(node, dataType, MAC)
|
||||||
|
cursor = mydb.cursor(dictionary=True) # Enable dictionary output
|
||||||
|
cursor.execute(query)
|
||||||
|
result = cursor.fetchall() # Fetch the results
|
||||||
|
cursor.close()
|
||||||
|
mydb.close()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True, host='localhost')
|
app.run(debug=True, host='localhost')
|
@@ -54,3 +54,10 @@ and im going to continue with working on the connection between the websocket an
|
|||||||
15 - 3- 2024 {
|
15 - 3- 2024 {
|
||||||
We are all making preperations for the sprint-review.
|
We are all making preperations for the sprint-review.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3/19/2024
|
||||||
|
|
||||||
|
Dano, oop arduino
|
||||||
|
Bram, nodes registereen als er een nieuwe binnenkomt
|
||||||
|
Sietse, onderdelen bestellen, verder user story 46: nodes beheren op website.
|
||||||
|
Sam, tft scherm, rest api ombouwen om data in node tabel te douwen
|
Reference in New Issue
Block a user