def __init__(self, destination_db_map, source_db, destination_db, config, counter, logger): self._destination_db_map = destination_db_map self._increment_step = config.increment_step self._orphaned_rows_update_values = config.orphaned_rows_update_values self._source_db = source_db self._destination_db = destination_db self._config = config self._counter = counter self._logger = logger self._conn = create_connection(self._source_db) self._cursor = self._conn.cursor() self.prepare_db() self._logger.log("Processing database '%s'..." % self._source_db['db']) # Indexes may be named differently in each database, therefore we need # to remap them self._logger.log(" -> 1/2 Re-mapping database") self._source_mapper = Mapper(self._conn, source_db['db'], MiniLogger(), verbose=False) db_map = self._source_mapper.map_db() self._logger.log(" -> 2/2 Re-applying FKs mapping to current database schema - in case execution broke before") map_fks(db_map, True) self._db_map = db_map
def __init__(self, destination_db_map, source_db, destination_db, config, counter, logger): self._destination_db_map = destination_db_map self._increment_step = config.increment_step self._source_db = source_db self._destination_db = destination_db self._config = config self._counter = counter self._logger = logger self._conn = create_connection(self._source_db) self._cursor = self._conn.cursor() self.prepare_db() self._logger.log("Processing database '%s'..." % self._source_db['db']) # Indexes may be named differently in each database, therefore we need # to remap them self._logger.log(" -> Re-mapping database") self._source_mapper = Mapper(self._conn, source_db['db'], config, MiniLogger(), verbose=False) db_map = self._source_mapper.map_db() self._db_map = db_map
def __init__(self, destination_db_map, source_db, destination_db, config, counter, logger): self._destination_db_map = destination_db_map self._increment_step = config.increment_step self._orphaned_rows_update_values = config.orphaned_rows_update_values self._source_db = source_db self._destination_db = destination_db self._config = config self._counter = counter self._logger = logger self._conn = create_connection(self._source_db) self._cursor = self._conn.cursor() self.prepare_db() self._logger.log("Processing database '%s'..." % self._source_db["db"]) # Indexes may be named differently in each database, therefore we need # to remap them self._logger.log(" -> 1/2 Re-mapping database") self._source_mapper = Mapper(self._conn, source_db["db"], MiniLogger(), verbose=False) db_map = self._source_mapper.map_db() self._logger.log(" -> 2/2 Re-applying FKs mapping to current database schema - in case execution broke before") map_fks(db_map, False) self._db_map = db_map
# VALIDATE CONFIG: if len(config.merged_dbs) == 0: print "You must specify at least one database to merge" sys.exit() # Prepare logger ##################################################################### # STEP 1 - map database schema, relations and indexes print "STEP 1. Initial mapping of DB schema" print " -> 1.1 First merged db" mapped_db = config.merged_dbs[0] conn = create_connection(mapped_db, config.common_data) mapper = Mapper(conn, mapped_db['db'], MiniLogger()) db_map = mapper.map_db() conn.close() print " -> 1.2 Destination db" conn = create_connection(config.destination_db, config.common_data) mapper = Mapper(conn, config.destination_db['db'], MiniLogger()) destination_db_map = mapper.map_db() conn.close()