Datahood
A friendly toolkit and CLI to transfer and stream data between databases using async pipelines, plus automatic schema inference that generates TypedDict and Pydantic models from your existing documents.
This tool was born from repeatedly writing throwaway scripts to move data from point A to point B across various client projects. Instead of reinventing the wheel every time, I extracted this into a reusable solution. If it saves you from writing ad-hoc data transfer scripts, it has fulfilled its purpose!
🎯 What It Does
Datahood solves two common data engineering problems:
- Data Transfer - Move data between MongoDB collections and BSON files with streaming performance
- Schema Discovery - Automatically generate Python type definitions from your existing documents
Perfect for:
- Moving production data slices to staging/development environments
- Creating typed models from legacy collections for safer refactoring
- Auditing document structure before migrations
- Quick data exports and imports with compression support
🚀 Quick Start
# Get help
dh --help
dh transfer --help
dh schema --help
# Transfer data
dh transfer mongo-to-bson output.bson --source-uri mongodb://localhost --source-collection users
dh transfer bson-to-mongo data.bson --dest-uri mongodb://localhost --dest-collection users
# Generate Python types
dh schema from-mongo --uri mongodb://localhost --collection users --to-pydantic -o models.py
dh schema from-bson data.bson --to-typeddict -o models.py
📦 Installation
uv add datahood # or pip install datahood
👷 Data Transfer
TIP: Add
--dry-runto any command to preview without moving data
MongoDB → BSON
dh transfer mongo-to-bson output.bson \
--source-uri "mongodb://user:pass@localhost:27017/?authSource=admin" \
--source-database mydb \
--source-collection users
BSON → MongoDB
dh transfer bson-to-mongo data.bson \
--dest-uri "mongodb://user:pass@localhost:27017/?authSource=admin" \
--dest-database mydb \
--dest-collection users
MongoDB → MongoDB
dh transfer mongo-to-mongo \
--source-uri "mongodb://source:27017" \
--source-database src_db --source-collection users \
--dest-uri "mongodb://dest:27017" \
--dest-database dest_db --dest-collection users_copy
🧬 Schema Generation
From MongoDB
# Generate Pydantic models
dh schema from-mongo --uri mongodb://localhost --collection users --to-pydantic -o models.py
# Generate TypedDict (default)
dh schema from-mongo --uri mongodb://localhost --collection users -o models.py
From BSON Files
# Generate Pydantic models
dh schema from-bson data.bson --to-pydantic -o models.py
# Generate TypedDict
dh schema from-bson data.bson --to-typeddict -o models.py
Smart Features:
- Automatically handles nested objects and creates separate types
- Detects optional fields and union types
- Generates clean, production-ready code
🧪 Development
make format lint type-check test # Quality checks
make test-mongo-up # Start test MongoDB
RUN_INTEGRATION=1 pytest tests/integration
make test-mongo-down # Clean up
🤝 Contributing
- Fork & create feature branch
- Add changes with tests
- Run:
make format lint type-check test - Submit PR
Version bumps: make bump-version PART=patch|minor|major
📬 Support
Issues: https://github.com/ericmiguel/datahood/issues
Happy data moving! ✨
Metadata
Release files for datahood 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| datahood-0.1.0.tar.gz | 194.5 kB | Without provenance | Details for datahood-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| datahood-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for datahood-0.1.0-py3-none-any.whl |
Total release size: 243.3 kB
Release files / datahood-0.1.0.tar.gz
| Download URL | datahood-0.1.0.tar.gz |
|---|---|
| Size | 194.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
633efa546b9590d1782907dbec49ab4750c76c92b9c5c121749313336c755085
|
|
BLAKE2b-256 checksum How to use checksums |
d36e9d6aef889f85884189db25e9375eda4fa5ad32f8e870a4dbd50838ddcd00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.3
|
Release files / datahood-0.1.0-py3-none-any.whl
| Download URL | datahood-0.1.0-py3-none-any.whl |
|---|---|
| Size | 48.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9d617810cbe9f8df8a2968d9e1bed617dfaf248fa3b5b70fe79bf4d8301f2ab6
|
|
BLAKE2b-256 checksum How to use checksums |
698860c4442a0109ef26efbab4175de9c5697f6780271925e044265f0b714466
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.3
|
Security for datahood 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.