websocket, database, file made.
This commit is contained in:
26
server/web-data-connection/databaseGeneralClass.py
Normal file
26
server/web-data-connection/databaseGeneralClass.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import mysql.connector
|
||||
|
||||
def dbLogin():
|
||||
mydb = mysql.connector.connect(
|
||||
host="localhost",
|
||||
user="root",
|
||||
password="Dingleberries69!",
|
||||
database="NodeData"
|
||||
)
|
||||
return mydb
|
||||
|
||||
class Node():
|
||||
def __init__(self, macAdress):
|
||||
self.macAdress = macAdress
|
||||
self.id = None
|
||||
|
||||
def getNodeId(self):
|
||||
id = (self.macAdress,)
|
||||
mydb = dbLogin()
|
||||
cursor = mydb.cursor()
|
||||
cursor.execute("""SELECT nodeID FROM Node WHERE MAC = %s""", id)
|
||||
data = cursor.fetchall()
|
||||
|
||||
for tuples in data:
|
||||
for item in tuples:
|
||||
self.id = item
|
Reference in New Issue
Block a user