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
Exemple #2
0
    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
Exemple #3
0
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()



print ""
print "STEP 2. Map all the fields that looks like FKs but aren't stored as ones"
map_fks(db_map)


print ""
print "STEP 3. Actually merge all the databases"
print ""
counter = 0
for source_db in config.merged_dbs:
 counter = counter + 1
 try:
  source_db_tpl = copy.deepcopy(config.common_data)
  source_db_tpl.update(source_db)
  
  destination_db_tpl = copy.deepcopy(config.common_data)
  destination_db_tpl.update(config.destination_db)