A CLI tool to export and import schema definitions and data from CockroachDB in SQL, JSON, YAML, or chunked CSV formats.
Project description
crdb-dump
A CLI tool to export and import schema definitions and data from CockroachDB in SQL, JSON, YAML, or chunked CSV formats.
Supports chunking, parallelism, resumability, diffing, manifest checksums, BYTES and UUID types, TLS auth, and dry-run safety.
🚀 Features
- Export tables, views, sequences, and user-defined types
- Output formats: SQL, JSON, YAML, CSV (with optional gzip)
- Export BYTES as
decode('<hex>', 'hex') - Handles UUIDs, TIMESTAMPS, arrays
- Create per-table schema files or a unified schema file
- Parallel + chunked data export with manifest and row tracking
- Resumable
COPY-based data import - Schema + data
dry-runmode - Schema diffing against previous .sql
- CLI output + logging to
logs/ - TLS certs or insecure connection supported
--print-connectionshows full resolved DB URL (safe)
🔧 Installation
pip install crdb-dump
🥺 Local Testing
Run an integration test:
./test-local.sh
This performs:
- Schema + data export (with BYTES, UUID)
- Chunked CSV manifest creation
- Dry-run import
- Full schema and data reload
🗋 Usage
crdb-dump export --db=mydb [options]
crdb-dump load --db=mydb --schema=<.sql> --data-dir=...
🔐 Connection Options
export CRDB_URL="cockroachdb://root@localhost:26257/defaultdb?sslmode=disable"
or use flags:
--db mydb --host localhost --certs-dir ~/certs
🏠 Export Options
crdb-dump export --db=mydb --data --data-format=csv --chunk-size=1000
| Option | Description |
|---|---|
--data |
Enable data export |
--data-format |
csv or sql output |
--data-compress |
Output .csv.gz instead |
--chunk-size |
Split into fixed-row chunks |
--per-table |
Write per-table files |
--data-order |
Order rows (e.g., by id) |
--data-order-desc |
Order descending |
--data-parallel |
Export tables in parallel |
--verify |
Check manifest SHA256s |
--print-connection |
Show resolved DB connection URL |
--archive |
Create .tar.gz from exported folder |
🛬 Load Options
crdb-dump load \
--db=mydb \
--schema=defaultdb_schema.sql \
--data-dir=export/defaultdb \
--resume-log=resume.json \
--print-connection \
--dry-run
| Option | Description |
|---|---|
--schema |
Load schema from .sql file |
--data-dir |
Path containing chunked CSVs and manifests |
--resume-log |
Resume tracking file for chunked load |
--dry-run |
Don't execute, just print plan |
--include-tables |
Restrict to specific table names |
--exclude-tables |
Skip specific table names |
--print-connection |
Print resolved CockroachDB connection |
📂 Output Structure
By default, output is stored under:
crdb_dump_output/<db_name>/
├── defaultdb_schema.sql
├── table_users.sql
├── users_chunk_001.csv
├── users.manifest.json
├── logins_chunk_001.csv
├── logins.manifest.json
All logs go to:
logs/crdb_dump.log
📄 Example: Full Export + Verify + Import
crdb-dump export \
--db=defaultdb \
--data \
--data-format=csv \
--chunk-size=1000 \
--per-table \
--verify \
--archive \
--print-connection
crdb-dump load \
--db=defaultdb \
--schema=crdb_dump_output/defaultdb/defaultdb_schema.sql \
--data-dir=crdb_dump_output/defaultdb \
--resume-log=resume.json \
--print-connection
🔍 Schema Diffing
crdb-dump export \
--db=defaultdb \
--diff=previous_schema.sql
This prints a unified diff and writes to:
crdb_dump_output/<db_name>/<db_name>_schema.diff
🤖 Test Coverage
pytest -m unit– runs fast unit testspytest -m integration– full Docker-based test./test-local.sh– end-to-end data roundtrip
🛠️ Developer Notes
- Configured via
pyproject.toml(PEP 621) - Click-based CLI
- Tested with CRDB v25.2
- CI runs all tests via GitHub Actions and Docker
👤 Author
Created by Virag Tripathi MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crdb_dump-0.2.1.tar.gz.
File metadata
- Download URL: crdb_dump-0.2.1.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68d97c9bf3759a4a052d1f19cccee33a8a8d26db9256e34a75710c488b83ee01
|
|
| MD5 |
7ea4f7d5779fb8e321943cd6a85a5d1f
|
|
| BLAKE2b-256 |
68806537ab68955d4c056bfe5b5291a20462f865ae45aca65c6f389924392de9
|
File details
Details for the file crdb_dump-0.2.1-py3-none-any.whl.
File metadata
- Download URL: crdb_dump-0.2.1-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d08d48596b3d1fedb1fec99c253e34dab8002bc9184dd3474d617d91cfd0f20
|
|
| MD5 |
c6b46ac2e3ad3a7a0869a3ad9b3c0bea
|
|
| BLAKE2b-256 |
8c85bf4e4dca90ee5240cf2c20f0b9f199486fb759cae045cc74cc9f90d0180c
|