Ejemplo n.º 1
0
 def set(self, key, value):
     sql = Database(self.filePath)
     if sql.is_present("SELECT * FROM wlc_settings WHERE key=?",(key,)):
         sql.write_data("UPDATE wlc_settings SET value=? WHERE key=?",(value,key,))
     else:
         sql.write_data("INSERT INTO wlc_settings (key,value) VALUES (?,?)",(key,value,))
     sql.commit()
Ejemplo n.º 2
0
 def save_data(self, ap_data):
     sql = Database(self.filePath)
     paramList = []
     timestamp = time.time()
     for ap in ap_data:
         params = (str(ap['key']),)
         query = "SELECT * FROM wlc_aps WHERE ap_key=?"
         apPresent = sql.is_present(query,params)
         if apPresent:
             params = (str(ap['name']),str(ap['location']),str(ap['key']))
             query = "UPDATE wlc_aps SET ap_name=?, ap_location=? WHERE ap_key=?"
             sql.write_data(query, params)
         else:
             params = (str(ap['key']),str(ap['name']),str(ap['location']))
             query = "Insert INTO wlc_aps (ap_key,ap_name,ap_location) VALUES (?,?,?)"
             sql.write_data(query,params)
         params = (str(ap['key']),str(timestamp),str(ap['clients']),)
         paramList.append(params)
     query = "INSERT INTO wlc_ap_clients (ap_key, timestamp , clients) VALUES (?,?,?)"
     sql.write_data_dump(query,paramList)
     sql.commit()