Generate Type Mapping Between Source and Target Databases
Type mapping is required to understand the behavior of data when replication occurs between different source and target databases. Oracle GoldenGate supports many source and target database replication combinations. You can determine the type mapping for any of these combinations using the MappingGenerator.py script.
The MappingGenerator.py is a Python script that generates type mappings between source and target databases based on the available JSON configuration files.
Prerequisites
Following are the prerequisites for using the MappingGenerator.py script:
- Python 3.x must be installed.
jsonandtxtlibraries (part of the Python Standard Library) must exist.argparselibrary (part of the Python Standard Library) must exist.
Run the MappingGenerator.py Script
To run the MappingGenerator.py script, use the following command:
python MappingGenerator.py source_json_file target_json_file output_txt_file>
In this command:
source_json_file: Path to the source JSON configuration file.target_json_file: Path to the target JSON configuration file.output_txt_file: Path to the output text file that will contain the generated mappings.
NOTE: Make sure that the output path is different from the path containing the MappingGenerator.py and any of the input JSON files.
{. :infoboxnote}
You can use the source_json_file and target_json_file present under MappingJSON directory.
The source_json_file file name looks similar to AutoSchemadatabase_nameSourceMappings.json,
while the target_json_file file name looks similar to AutoSchemadatabase_nameTargetMappings.json.
You may choose source_json_file and target_json_file of any database supported by Oracle GoldenGate Autoschema mapping.
Example
The following example demonstrates generation of MySQL to Oracle autoschema type mapping:
python MappingGenerator.py ./MappingJSON/AutoSchemaMySQLSourceMappings.json ./MappingJSON/AutoSchemaOracleTargetMappings.json /tmp/MySQL_to_Oracle_autoschema_mappings.txt
The script generates a text file with the name as specified in the third argument. This file contains the generated type mappings in a human-readable format. For samples of type mappings, see Data Type Mapping
Guidelines for Using MappingGenerator.py
The following considerations are important when using the MappingGenerator.py script:
- Ensure that the input JSON files are valid and follow the expected format.
- Verify that the output directory exists and is writable.