ch-sink-tools

April 7, 2026 · View on GitHub

PostgreSQL/MySQL to ClickHouse CDC verification and snapshot tools.

Installation

# PostgreSQL-only (primary use case):
pip install ch_sink_tools-0.2.0-py3-none-any.whl

# With MySQL support:
pip install "ch_sink_tools-0.2.0-py3-none-any.whl[mysql]"

# Everything (MySQL + pandas):
pip install "ch_sink_tools-0.2.0-py3-none-any.whl[all]"

CLI Commands

CommandDescription
ch-checksumFull PG→CH checksum orchestrator (top-level)
ch-pg-checksumSingle-table PostgreSQL checksum
ch-pg-countPostgreSQL row count comparison
ch-ch-checksumClickHouse-side checksum
ch-ch-countClickHouse row count
ch-pg-dumpPostgreSQL → ClickHouse snapshot loader
ch-mysql-checksumMySQL checksum (requires [mysql] extra)
ch-mysql-dumpMySQL dump (requires [mysql] extra)
ch-mysql-loadMySQL → ClickHouse loader (requires [mysql] extra)

Quick Start

# Run checksum verification
ch-checksum --config /path/to/config.yml

# Single-table checksum with debug
ch-checksum --config config.yml --table my_table --debug

# Count-only check
ch-pg-count --config config.yml

# Snapshot load from PostgreSQL
ch-pg-dump --pg-host pgserver --ch-host chserver --pg-database mydb

Building

pip install build
python -m build --wheel
# Produces: dist/ch_sink_tools-0.2.0-py3-none-any.whl

Deploying

# Build + deploy in one step:
./build_wheel.sh --deploy

# Or manually:
scp dist/ch_sink_tools-*.whl user@ch-server:/tmp/
ssh user@ch-server '/opt/python-dump/.venv/bin/pip install --force-reinstall /tmp/ch_sink_tools-*.whl'

Dependencies

Core (always installed):

  • clickhouse-driver>=0.2.9
  • psycopg2-binary
  • pyyaml

Optional:

  • [mysql]: pymysql, sqlalchemy>=1.4, antlr4-python3-runtime==4.11.1
  • [dataframe]: pandas