diff --git a/data/scripts/migrator/dbsmerge_mongo.py b/data/scripts/migrator/dbsmerge_mongo.py index 7d983a0c1..316048985 100755 --- a/data/scripts/migrator/dbsmerge_mongo.py +++ b/data/scripts/migrator/dbsmerge_mongo.py @@ -6,6 +6,15 @@ # ^ the script will "move" the collections if source and target server are the same # but will "copy" (dump/restore) if source and target servers are different +import os +import shutil +import subprocess +import sys +from collections import OrderedDict +from urllib import quote_plus + +from pymongo import MongoClient + from_host = '127.0.0.1' from_port = '27017' from_db = '11' @@ -31,11 +40,6 @@ drop_target = False dump_folder = 'dump' -import sys -from pymongo import MongoClient -from urllib import quote_plus -from collections import OrderedDict - # same server if from_host == to_host and from_port == to_port: print('Migrating on same server...') @@ -68,10 +72,6 @@ if from_host == to_host and from_port == to_port: # different servers else: - import subprocess - import os - import shutil - print('Migrating between different servers...') print('Dumping...') out = subprocess.check_output([ diff --git a/data/scripts/migrator/dbsmerge_redis.py b/data/scripts/migrator/dbsmerge_redis.py index 9faf01ea3..f68a465a2 100755 --- a/data/scripts/migrator/dbsmerge_redis.py +++ b/data/scripts/migrator/dbsmerge_redis.py @@ -8,6 +8,10 @@ # behaviour: # ^ the script will not overwrite keys on the destination server/database +import time + +import redis + from_host = '127.0.0.1' from_port = 6379 from_db = 11 @@ -21,9 +25,6 @@ to_pass = '' # Not used keymask = '*' timeout = 2000 -import time -import redis - from_redis = redis.Redis(host = from_host, port = from_port, password=from_pass, db = from_db) to_redis = redis.Redis(host = to_host, port = to_port, db = to_db) diff --git a/data/scripts/migrator/usage_mysql.py b/data/scripts/migrator/usage_mysql.py index 66f20ad5d..75e6b334d 100755 --- a/data/scripts/migrator/usage_mysql.py +++ b/data/scripts/migrator/usage_mysql.py @@ -3,14 +3,14 @@ # depends: # ^ mysql (debian: python-mysql.connector) +import mysql.connector + host = '127.0.0.1' port = 3306 database = 'cgrates' user = 'root' password = 'CGRateS.org' -import mysql.connector - config = { 'user': user, 'password': password, diff --git a/data/scripts/migrator/usage_postgres.py b/data/scripts/migrator/usage_postgres.py index 621321f8a..f9aa7816f 100644 --- a/data/scripts/migrator/usage_postgres.py +++ b/data/scripts/migrator/usage_postgres.py @@ -3,14 +3,14 @@ # depends: # ^ psycopg2 (debian: python-psycopg2) +import psycopg2 + host = '127.0.0.1' port = 5432 database = 'cgrates' user = 'cgrates' password = 'CGRateS.org' -import psycopg2 - print('Connecting to PostgreSQL...') cnx = psycopg2.connect( host=host,