From 367bb814dd71d99b896aa4c6ce8d2c7940ad4bfe Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 31 Aug 2020 19:03:00 +0800 Subject: [PATCH] 1 --- tools/migratedb/6000/mysql.json | 9 +++++++++ tools/migratedb/6000/redis.json | 9 +++++++++ tools/migratedb/common/mysql_rule.json | 3 +++ tools/migratedb/common/redis_rule.json | 3 +++ tools/migratedb/migratedb.py | 16 +++++++++++----- 5 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 tools/migratedb/6000/mysql.json create mode 100644 tools/migratedb/6000/redis.json create mode 100644 tools/migratedb/common/mysql_rule.json create mode 100644 tools/migratedb/common/redis_rule.json diff --git a/tools/migratedb/6000/mysql.json b/tools/migratedb/6000/mysql.json new file mode 100644 index 0000000..c2754a2 --- /dev/null +++ b/tools/migratedb/6000/mysql.json @@ -0,0 +1,9 @@ +[ + { + "instance_id" : 1, + "host" : "127.0.0.1", + "port" : 3306, + "user" : "root", + "passwd" : "keji178" + } +] diff --git a/tools/migratedb/6000/redis.json b/tools/migratedb/6000/redis.json new file mode 100644 index 0000000..c2754a2 --- /dev/null +++ b/tools/migratedb/6000/redis.json @@ -0,0 +1,9 @@ +[ + { + "instance_id" : 1, + "host" : "127.0.0.1", + "port" : 3306, + "user" : "root", + "passwd" : "keji178" + } +] diff --git a/tools/migratedb/common/mysql_rule.json b/tools/migratedb/common/mysql_rule.json new file mode 100644 index 0000000..41b42e6 --- /dev/null +++ b/tools/migratedb/common/mysql_rule.json @@ -0,0 +1,3 @@ +[ + +] diff --git a/tools/migratedb/common/redis_rule.json b/tools/migratedb/common/redis_rule.json new file mode 100644 index 0000000..41b42e6 --- /dev/null +++ b/tools/migratedb/common/redis_rule.json @@ -0,0 +1,3 @@ +[ + +] diff --git a/tools/migratedb/migratedb.py b/tools/migratedb/migratedb.py index 0b7c2c0..6e9a67e 100644 --- a/tools/migratedb/migratedb.py +++ b/tools/migratedb/migratedb.py @@ -10,9 +10,10 @@ import time import datetime import redis import os +import sys import functools -CONFIG_DIR = '.' +CONFIG_DIR = './' context = { 'channel': 0, 'dbname_prefix': '' @@ -55,11 +56,16 @@ def exportRedis(context, redis_conf, redis_rule_conf): def main(): global context - db_conf = json.loads(open(CONFIG_DIR + '/mysql_list.json', 'r').read()) - redis_conf = json.loads(open(CONFIG_DIR + '/redis_list.json', 'r').read()) - db_rule_conf = json.loads(open(CONFIG_DIR + '/mysql_rule.json', 'r').read()) - redis_rule_conf = json.loads(open(CONFIG_DIR + '/redis_rule.json', 'r').read()) + if not os.path.exists(CONFIG_DIR + 'out/'): + os.mkdir(CONFIG_DIR + 'out/') + if not os.path.exists(CONFIG_DIR + 'out/' + context['channel']): + os.mkdir(CONFIG_DIR + 'out/' + context['channel']) + db_conf = json.loads(open(CONFIG_DIR + context['channel'] + '/mysql.json', 'r').read()) + redis_conf = json.loads(open(CONFIG_DIR + context['channel'] + '/redis.json', 'r').read()) + db_rule_conf = json.loads(open(CONFIG_DIR + 'common/mysql_rule.json', 'r').read()) + redis_rule_conf = json.loads(open(CONFIG_DIR + 'common/redis_rule.json', 'r').read()) exportRedis(context, redis_conf, redis_rule_conf) if __name__ == "__main__": + context['channel'] = sys.argv[1] main()