Metadata-Version: 2.4
Name: database_migration
Version: 0.1.0
Summary: Professional database cloning tool for PostgreSQL and MySQL
Project-URL: Homepage, https://github.com/carbler/database_migration
Project-URL: Repository, https://github.com/carbler/database_migration
Project-URL: Issues, https://github.com/carbler/database_migration/issues
Author-email: Erley <erley@example.com>
License-Expression: MIT
License-File: LICENSE
Keywords: clone,database,migration,mysql,postgresql
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: System :: Systems Administration
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: psycopg2-binary>=2.9.9
Requires-Dist: pydantic-settings>=2.0.0
Requires-Dist: pydantic>=2.5.0
Requires-Dist: pymysql>=1.1.0
Requires-Dist: rich>=13.7.0
Requires-Dist: structlog>=24.1.0
Requires-Dist: typer[all]>=0.9.0
Provides-Extra: dev
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest-mock>=3.12; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: testcontainers[mysql,postgres]>=3.7; extra == 'dev'
Description-Content-Type: text/markdown

# db-clone

Professional database cloning tool for PostgreSQL and MySQL.

Clone entire databases including schemas, tables, data, indexes, foreign keys, views, functions, triggers, and more — with streaming transfer for large databases, checkpoint/resume support, and Rich progress UI.

## Installation

```bash
pip install db-clone
```

## Quick Start

```bash
# Clone a PostgreSQL database
db-clone clone \
    --source "postgresql://user:pass@source-host:5432/mydb" \
    --target "postgresql://user:pass@target-host:5432/mydb_clone"

# Clone with options
db-clone clone \
    --source "postgresql://user:pass@host/db" \
    --target "postgresql://user:pass@host/db_clone" \
    --strategy overwrite \
    --batch-size 10000 \
    --exclude-tables "temp_*,log_*"

# Resume an interrupted migration
db-clone clone --source "..." --target "..." --resume

# Schema only (no data)
db-clone clone --source "..." --target "..." --schema-only

# Data only (tables must exist)
db-clone clone --source "..." --target "..." --data-only
```

## Commands

```bash
db-clone clone       # Clone a database
db-clone info        # Show database information
db-clone validate    # Validate source matches target
db-clone checkpoint show   # Show checkpoint state
db-clone checkpoint clear  # Clear checkpoint
```

## Features

- **PostgreSQL → PostgreSQL** and **MySQL → MySQL** cloning
- **11-phase ordered copy**: schemas, extensions, types, sequences, tables, data, indexes, foreign keys, views, functions, triggers
- **Streaming transfer**: server-side cursors + batched inserts (no memory issues on large DBs)
- **Checkpoint/resume**: interrupt anytime with Ctrl+C, resume with `--resume`
- **Conflict strategies**: `overwrite` (default), `skip`, `fail`
- **Table filtering**: `--include-tables` and `--exclude-tables` with glob patterns
- **Rich progress UI**: live progress bars, summary tables
- **Structured logging**: file-based logs via structlog

## Environment Variables

Instead of CLI options, you can use environment variables:

```bash
export DB_CLONE_SOURCE_URL="postgresql://user:pass@host:5432/db"
export DB_CLONE_TARGET_URL="postgresql://user:pass@host:5432/db_clone"
export DB_CLONE_BATCH_SIZE=5000
export DB_CLONE_LOG_LEVEL=INFO
```

## Development

```bash
pip install -e ".[dev]"
pytest tests/unit/ -v
pytest tests/integration/ -v --run-integration  # requires Docker
```

## License

MIT
