def convert_query_cache_to_json(): import cPickle from r2.models.query_cache import json, UserQueryCache with UserQueryCache._cf.batch() as m: for key, columns in UserQueryCache._cf.get_range(): out = {} for ckey, cvalue in columns.iteritems(): try: raw = cPickle.loads(cvalue) except cPickle.UnpicklingError: continue out[ckey] = json.dumps(raw) m.insert(key, out)