import mysql.
connector
import pytuya;
import time;
def establish_database_connection(username="root", paswd="raspberry", db_name=
"exampledb"):
mydb = [Link](host = "localhost",
user = username,
password = paswd, database = db_name)
mycursor = [Link]()
return mydb, mycursor
class Network:
def __init__(self):
return
class Device:
def __init__(self,device_Id,device_Ip,device_Key='12345678'):
self.device_Id=device_Id
self.device_Ip=device_Ip
self.device_Key=device_Key
[Link] = None
def establish_device_connection(pass):
try:
[Link]=
[Link](self.device_Id,self.device_Ip,self.device_Key)
except:
print("Device Connection Failed. Please try again.")
return None
def data_logging(self, db, cursor):
cmd = "INSERT INTO powerMeasurement1(power) VALUES (%s)"
data = [Link]()
val = (int(data1['dps']['5']),)
[Link](cmd,val)
[Link]()