Metadata-Version: 2.5
Name: omnidbm
Version: 0.1.0
Summary: Universal database-to-database transfer engine with an interactive CLI (MongoDB, PostgreSQL, MySQL, SQLite, Redis, CSV, JSONL)
Author: Aritra
License: MIT
License-File: LICENSE
Keywords: cli,csv,database,jsonl,migration,mongodb,mysql,postgresql,redis,sqlite,transfer
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
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 :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: psycopg[binary]>=3.1
Requires-Dist: pymongo>=4.6
Requires-Dist: rich>=13.0
Requires-Dist: typer>=0.12
Provides-Extra: all
Requires-Dist: pymysql>=1.1; extra == 'all'
Requires-Dist: redis>=5.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: pymysql>=1.1; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: redis>=5.0; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Provides-Extra: mysql
Requires-Dist: pymysql>=1.1; extra == 'mysql'
Provides-Extra: redis
Requires-Dist: redis>=5.0; extra == 'redis'
Description-Content-Type: text/markdown

# omnidbm

Universal database-to-database transfer engine with an interactive CLI.
Transfer any supported source to any supported destination: MongoDB, PostgreSQL, MySQL, SQLite, Redis, CSV, JSONL.

## Install

```bash
pip install omnidbm
pip install "omnidbm[mysql]"    # MySQL support
pip install "omnidbm[redis]"    # Redis support
pip install "omnidbm[all]"      # everything
```

## CLI

```bash
# Transfer all tables
omnidbm transfer --source mongodb://user:pass@host/db --dest postgresql://user:pass@host/db

# Specific tables, batch size, drop destination first
omnidbm transfer -s mongodb://... -d postgresql://... -t users,orders --batch-size 2000 --drop-first

# Count only, no writes
omnidbm transfer -s csv://./data -d mongodb://... --dry-run

# Interactive guided wizard
omnidbm wizard

# Inspect a source
omnidbm inspect mongodb://user:pass@host/db --sample 3

# Connectivity preflight
omnidbm doctor mongodb://... postgresql://...
```

### Options

| Flag | Description |
| --- | --- |
| `-s, --source` | Source URI (`mongodb://`, `mongodb+srv://`, `postgresql://`, `csv://`, `jsonl://`) |
| `-d, --dest` | Destination URI (same schemes) |
| `-t, --tables` | Comma-separated table names (default: all) |
| `--batch-size` | Documents per batch (default 1000) |
| `--drop-first` | Drop destination table before transfer |
| `--dry-run` | Count documents only, no writes |
| `--limit` | Max documents per table |
| `--filter` | Source-side JSON query filter, e.g. `{"status":"active"}` |
| `--conflict` | `skip` (default), `overwrite`, or `error` |
| `--copy-indexes/--no-copy-indexes` | Copy indexes (MongoDB only) |
| `--copy-options/--no-copy-options` | Copy collection options (MongoDB only) |

### URI schemes

- `mongodb://user:pass@host:27017/db` or `mongodb+srv://...`
- `postgresql://user:pass@host:5432/db`
- `mysql://user:pass@host:3306/db`
- `sqlite://C:/path/db.sqlite` or `sqlite://:memory:`
- `redis://user:pass@host:6379/0` — tables are key prefixes (split on `:`), `(all)` for every key
- `csv://C:/path/to/file.csv` or `csv://C:/data/` (directory = multiple tables)
- `jsonl://C:/path/out.jsonl` or `jsonl://C:/data/`

Redis documents use the shape `{"_key": ..., "_value": ..., "_ttl": ...}`: strings, hashes (dict),
and lists/sets (list) are supported. Keys missing the table prefix get it prepended on write.

## Python API

```python
from omnidbm import transfer, TransferConfig, ConnectorConfig, TableSpec

config = TransferConfig(
    source=ConnectorConfig(uri="mongodb://user:pass@host/db"),
    dest=ConnectorConfig(uri="postgresql://user:pass@host/db"),
    tables=[TableSpec(source="users", dest="users")],
    drop_first=True,
)
results = transfer(config)
```

Custom connectors: subclass `BaseConnector`, implement `connect`, `list_tables`, `read_stream`,
`write_stream`, `close`, then register with `@register("scheme")`.

## Notes

- Documents are normalized to JSON-safe values with type tags, so datetime, ObjectId,
  Binary, and Decimal survive any-to-any transfers losslessly.
- PostgreSQL/MySQL/SQLite destination tables are created automatically with inferred column types.
- MySQL and Redis drivers are optional: `pip install omnidbm[mysql]`, `pip install omnidbm[redis]`.
- CSV destinations require consistent keys across documents; use JSONL for heterogeneous data.
- `--conflict overwrite` on files behaves like append (files are immutable).