From 851129ab1f4f80515067be6c99ce0414b6e3c78c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 31 Aug 2020 19:36:57 +0800 Subject: [PATCH] 1 --- tools/migratedb/common/redis_rule.json | 2 +- tools/migratedb/migratedb.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/migratedb/common/redis_rule.json b/tools/migratedb/common/redis_rule.json index fcc63af..bd340bd 100644 --- a/tools/migratedb/common/redis_rule.json +++ b/tools/migratedb/common/redis_rule.json @@ -1,5 +1,5 @@ [ { - "key_prefix": "" + "key_prefix": "game2004" } ] diff --git a/tools/migratedb/migratedb.py b/tools/migratedb/migratedb.py index d3a8d93..64e6262 100644 --- a/tools/migratedb/migratedb.py +++ b/tools/migratedb/migratedb.py @@ -37,7 +37,6 @@ def scanKeys(r, key_prefix, matched_keys): #end while cursor def saveKeys(r, keys, curr_file): - print(keys) for key in keys: data = r.get(key) curr_file.write(json.dumps({'key': key, 'data':data}) + '\n') @@ -48,13 +47,13 @@ def exportRedis(context, redis_conf, redis_rule_conf): r = redis.Redis(host = conf['host'], port = conf['port'], password = conf['passwd'], - charset = 'utf8' + decode_responses = True ) print(r) for rule in redis_rule_conf: matched_keys = {} scanKeys(r, rule['key_prefix'], matched_keys) - saveKeys(r, curr_file, matched_keys) + saveKeys(r, matched_keys, curr_file) #end for conf def main():