Esempio n. 1
0
 def call_back(self,data=[]):
     
     
     db = Custom_MySQL(using='log')
     
     sql = "insert into last_ip (id,ip,login_ip) values(null,%s,%s)"
     
     for result in data:
         
         if int(result['flag']) == 1:
  
             ips = json.loads(result['data'])
             host = result['ip']
 
             set_param =[]
             for ip in ips:
                 set_param.append(tuple([host,ip]))
             db.executemany(sql,set_param)
             db.commit()
         else:
             print result
Esempio n. 2
0
 def call_back(self,data=[]):
         
     db = Custom_MySQL(using='log')   
     last_insert_id =  db.insert('cpu_batch',**{})
     db.commit()
     
     sql = "insert into cpu_detail (id,ip,cpu_used) values(null,%s,%s)"
     
     for result in data:
         
         if int(result['flag']) == 1:
  
             ips = json.loads(result['data'])
             host = result['ip']
 
             set_param =[]
             for ip in ips:
                 set_param.append(tuple([host,ip]))
             db.executemany(sql,set_param)
             db.commit()
         else:
             print result