Beispiel #1
0
class Ipv_Top:
    def __init__(self,files,top_x=20,db_settings=local_db_settings):
        self.data=IpCounter(files).get_data()
        self.top_x=sorted(self.data.items(),key=lambda x:x[1],reverse=True)[:top_x]
        self.connection = MySQL_Connection(db_settings)


    def store(self):

        keys='(day,topn,ip,freq)'
        for i,(ip,counts) in enumerate(self.top_x):
            self.connection.insert('top_ip',keys,(today,i+1,ip,counts))
Beispiel #2
0
 def __init__(self,files,top_x=20,db_settings=local_db_settings):
     self.data=IpCounter(files).get_data()
     self.top_x=sorted(self.data.items(),key=lambda x:x[1],reverse=True)[:top_x]
     self.connection = MySQL_Connection(db_settings)