class IpLocationService:
    def __init__(self,files,db_settings=server_183_db_settings):
        self.data=IpLocationCounter(files).get_data()
        # self.data=cPickle.load(open('CityIpData'))
        self.connection=MySQL_Connection(db_settings)
        cPickle.dump(self.data,open('CityIpData','wb'))

    def store(self):

        province_data={}

        for (city,province),count in self.data.items():
            self.connection.insert('city_ip',('day','city','count'),(today,city,count))
            province_data.setdefault(province,0)
            province_data[province]+=count
        for province,count in province_data.items():
            self.connection.insert('province_ip',('day','province','count'),(today,province,count))

        # print self.data
        # print province_data
 def __init__(self,files,db_settings=server_183_db_settings):
     self.data=IpLocationCounter(files).get_data()
     # self.data=cPickle.load(open('CityIpData'))
     self.connection=MySQL_Connection(db_settings)
     cPickle.dump(self.data,open('CityIpData','wb'))