def ips_to_sql(req): master_13 = RedisDriver().master_13 num = master_13.llen("all_ips_list") while master_13.llen("all_ips_list") > 0: ip = master_13.rpop("all_ips_list") ip_attribution = sina_ip(ip)[-3:-1] item = Access_ip() item.ip = ip item.ip_attribution = ip_attribution item.save() return HttpResponse("{0}-IP-TO_MYSQL".format(num))
def ips_to_sql(req): ips_to_sql = cache.get("ips_to_sql", []) num=0 if ips_to_sql: for ip in ips_to_sql: ips_to_sql.remove(ip) cache.set("ips_to_sql", ips_to_sql) ip_attribution = sina_ip(ip)[-3:-1] item = Access_ip() item.ip = ip item.ip_attribution = ip_attribution item.save() num+=1 access_log.info("{0}-IP-TO_MYSQL".format(num)) return HttpResponse("{0}-IP-TO_MYSQL".format(num))