old_contents: import os
  import cPickle as pickle
  import simplejson as json
  
  
  def update_pickle(new_cache):
      # print('Updated pickle')
      pickle.dump(new_cache, open('url_cache.pkl', 'wb'), 2)
  
  
  def check_pickle():
      # print('Checking in pickle')
      if not os.path.isfile('url_cache.pkl'):
          malicious_url = {}
          pickle.dump(malicious_url, open('url_cache.pkl', 'wb'), 2)
  
      cache = pickle.load(open('url_cache.pkl', 'rb'))
      return cache
  
  
  def update_json(data):
      with open("url_cache.json", "wb") as fp:
          try:
              json.dump(data, fp)
          except:
              print "UnicodeDecodeError: 'utf8' codec can't decode byte 0xb8"
  
  
  def check_json():
      if not os.path.isfile('url_cache.json'):
          init = {}
          with open("url_cache.json", "wb") as fp:
              json.dump(init, fp)
  
      with open("url_cache.json", "rb") as fp:
          # cache = json.load(fp)
          cache = json.load(fp, "ISO-8859-1")
      return cache
  
  
  def pickle2json(pkl):
      if os.path.isfile(pkl):
          cache = pickle.load(open(pkl, 'rb'))
          with open('pkl2json.json', 'wb') as fp:
              json.dump(cache, fp)
      else:
          print "No such file"
  
new_contents: import os
  import cPickle as pickle
  import simplejson as json
  import sql_tool
  
  
  def update_pickle(new_cache):
      # print('Updated pickle')
      pickle.dump(new_cache, open('url_cache.pkl', 'wb'), 2)
  
  
  def check_pickle():
      # print('Checking in pickle')
      if not os.path.isfile('url_cache.pkl'):
          malicious_url = {}
          pickle.dump(malicious_url, open('url_cache.pkl', 'wb'), 2)
  
      cache = pickle.load(open('url_cache.pkl', 'rb'))
      return cache
  
  
  def update_json(data):
      with open("url_cache.json", "wb") as fp:
          try:
              json.dump(data, fp)
          except:
              print "UnicodeDecodeError: 'utf8' codec can't decode byte 0xb8"
  
  
  def check_json():
      if not os.path.isfile('url_cache.json'):
          init = {}
          with open("url_cache.json", "wb") as fp:
              json.dump(init, fp)
  
      with open("url_cache.json", "rb") as fp:
          # cache = json.load(fp)
          cache = json.load(fp, "ISO-8859-1")
      return cache
  
  
  def pickle2json(pkl):
      if os.path.isfile(pkl):
          cache = pickle.load(open(pkl, 'rb'))
          with open('pkl2json.json', 'wb') as fp:
              json.dump(cache, fp)
      else:
          print "No such file"
  
  
  def json2sql():
      db = sql_tool.SQLiteTool()
      db.creat()
  
      with open('pkl2json.json', 'r') as fp:
          cache = json.load(fp)
  
      for key, value in cache.iteritems():
          db.insert2(key, value[0], value[1])
      db.show()
  
subject: Add json convert to sql method