Use DataX
Overview
Use this skill to prepare and execute DataX syncs for project databases. It covers runtime config resolution, template-driven job generation, overwrite safety, execution, and fast failure reporting.
Configuration
Read runtime settings from the user's .codex config directory.
Only these values are externalized:
config_dir: directory that contains environment database config filesdatax_home: DataX installation rootjob_dir: directory for generated executable DataX JSON
Do not hardcode source/target environments, tables, columns, or date ranges in the skill.
Derive JDBC settings from the env config files under config_dir.
Treat any project-provided DataX JSON template as a structure reference only; when documenting or reproducing it, replace real credentials, hosts, and database names with placeholders.
Template First
When the project already contains a DataX JSON template, use it as the primary shape reference.
Prefer these adjustments over inventing a new layout:
- keep the same job nesting and writer overwrite pattern
- keep explicit column order aligned between reader and writer
- preserve project-specific JDBC option baselines
- keep file naming and output location driven by configuration
Do not copy real connection values into skill text or examples.
Workflow
- Ask for the source env, target env, table name(s), date range or filter, and whether overwrite/truncate is allowed.
- Resolve JDBC settings from
config_dir. - Generate DataX JSON into
job_dirwith explicit columns by default. - For overwrite syncs, set writer
preSql/postSqlto disable FK checks and truncate the target table. - Validate the JSON before execution: environment, table, columns, and overwrite SQL.
- Run DataX from
datax_home. - Stop on the first error and report per-table success/failure counts.
Rules
- Prefer explicit column lists for nontrivial tables.
- Use full overwrite only when the user confirms the target table should be cleared.
- Fail fast if the generated JSON points at the wrong environment.
- Keep generated job files under the configured
job_dir, not inside the skill. - When a project already has local DataX examples, align the generated jobs with those conventions instead of inventing new ones.
References
- See references/config.md for the external config boundary used by this skill.