Package: ptolemy
Ptolemy, an AWS DMS table mapping generatorWrite terse AWS DMS table mappings.BackgroundAmazon Web Services provides a tool for migrating data to, from or between SQL databases. This tool is namedDatabase Migration Service(DMS). When running DMS, users can supply a table mapping, which specifies allows the user to control what data is sent from the source database to the target database. A full list of table mapping options can be foundhere.Table mappings are written as JSON documents, which can grow to be long and complex.ptolemyallows the user to write terse YAMLsourcefiles, which can be compiled to valid JSON table mappings using theptolemycli tool.Usage$# Display an example source file:$catmigrate_all_tables_in_a_schema.yamlselection:
  include:
    -
      object-locators:
        schema-names:
          - Test
        table-names:
          - "%"$# Compile it to a DMS table mapping:$ptolemymigrate_all_tables_in_a_schema.yaml{
    "rules": [
        {
            "object-locator": {
                "schema-name": "Test",
                "table-name": "%"
            },
            "rule-action": "include",
            "rule-id": "1",
            "rule-name": "1",
            "rule-type": "selection"
        }
    ]
}API$ptolemy-hptolemy [-h] [-d] [-v] source

positional arguments:
  source         path to the source file

optional arguments:
  -h, --help     show this help message and exit
  -d, --debug    enable debug logs
  -v, --version  show program's version number and exitInstallInstall via pip (recommended):$pipinstallptolemyInstall from source:$gitclonegit@github.com:cloudreach/ptolemy.git$cdptolemy$makeinstallLicenseptolemy is licensed under the Apache Software License 2.0.Source SyntaxThe following sections describe the source syntax. It is intended to show users who have working knowledge of DMS JSON mapping files how to write their YAML equivalents. For an overview of the JSON mapping files, see thedocumentation. Most items are the same as those in JSON mapping files, with the exception ofobject-locators, which are explained in the sectionObject LocatorsThe descriptions are written in pseudo-yaml, where the syntax( option_a|option_b )indicates that an item could take the valueoption_aoroption_b.For working examples, see theexamples directory.Selection Rules and Actionsselection:( include|exclude ):-object-locators:schema-names:-<schema-name-1>table-names:-<table-name-1>filters:-filter-type:sourcecolumn-name:<column-name-1>filter-conditions:-filter-operator:( ste|gte|eq|between )value:<value>Transformation Rules and Actionstransformation:( rename|remove-column|convert-lowercase|convert-uppercase|add-prefix|remove-prefix|replace-prefix|add-suffix|remove-suffix|replace-suffix ):-object-locators:schema-names:-<schema-name-1>table-names:-<table-name-1>column-names:-<column-name-1>rule-target:( schema|table|column )value:<value>old-value:<old-value>Object Locatorsobject-locatorsoffer a powerful way to apply selection and transformation rules to large numbers of objects. The singularschema-name,table-nameandcolumn-nameparameters of the native JSON table mappingobject-locatorhave been replaced by their plurals. These new parameters each accept a list of objects. The rule is then applied to each column listed, for each table listed, for each schema listed.Multiple Source File CompilationMultiple source files can be compiled at once with the following Bash snippet. The snippet recursively finds all YAML files under the directorysrc/, compiles the source to a DMS mapping file, and saves it to a file with the same name and path under a directory namedmappings/, with the extension.json.source_files="$(findsrc-typef-name'*.yaml')"forsource_filein$source_files;dosource_file_without_extension=${source_file%.*}source_file_with_json_extension=${source_file_without_extension}.jsondestination_file=mappings${source_file_with_json_extension#src}mkdir-p"$(dirname$destination_file)"ptolemy$source_file>$destination_filedoneRunning the code from the following directory:.
└── src
  ├── db-a
  │   ├── schema-1.yaml
  │   └── schema-2.yaml
  └── db-b
      ├── schema-1.yaml
      └── schema-2.yamlwould result in:.
├── mappings
│   ├── db-a
│   │   ├── schema-1.json
│   │   └── schema-2.json
│   └── db-b
│       ├── schema-1.json
│       └── schema-2.json
└── src
    ├── db-a
    │   ├── schema-1.yaml
    │   └── schema-2.yaml
    └── db-b
        ├── schema-1.yaml
        └── schema-2.yamlHistory1.0.0 (2016-11-18)Initial release.