🍃 mongoexport
Export data from MongoDB collections with advanced features like pagination, configurable delays, and automatic retry logic.
Features
- Paginated Export: Efficiently export large collections using configurable batch sizes
- Retry Logic: Automatic retry mechanism with configurable attempts and delays
- Configurable Delays: Add delays between batches to avoid server overload
- JSON Export: Export data to JSON format using BSON serialization
- CLI Tool: Easy-to-use command-line interface
- Robust Error Handling: Comprehensive logging and error management
Installation
From PyPI
pip install mongoexport
From Source
git clone https://github.com/otsobide/mongoexport.git
cd mongoexport
pip install -e .
Usage
Command Line
mongoexport \
--uri mongodb://localhost:27017 \
--db mydb \
--collection mycollection \
--batch-size 1000 \
--delay 0.5 \
--retries 3 \
--retry-delay 2.0 \
--output export.json
Option Reference
| Option | Type | Default | Description |
|---|---|---|---|
--uri |
string | required | MongoDB connection URI (e.g., mongodb://localhost:27017) |
--db |
string | required | Database name |
--collection |
string | required | Collection name |
--batch-size |
int | 1000 | Number of documents per batch |
--delay |
float | 0.5 | Delay in seconds between batches |
--retries |
int | 3 | Number of retry attempts for failed batches |
--retry-delay |
float | 2.0 | Delay in seconds before retrying |
--output |
string | output.json | Output file path |
Python Module
from mongoexport import export_data
import argparse
# Create arguments namespace
args = argparse.Namespace(
uri="mongodb://localhost:27017",
db="mydb",
collection="mycollection",
batch_size=1000,
delay=0.5,
retries=3,
retry_delay=2.0,
output="export.json"
)
# Export data
export_data(args)
Requirements
- Python >= 3.8
- pymongo >= 3.12.0
Development
Setup Development Environment
git clone https://github.com/otsobide/mongoexport.git
cd mongoexport
pip install -e ".[dev]"
Running Tests
pytest
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Issues
If you encounter any issues, please report them on GitHub Issues.
Changelog
Version 0.1.4 (2026-08-24)
- Update project URLs to the
otsobideGitHub account - Fix the LICENSE link in this README
- Sync
__version__with the packaged version - No functional changes to the export logic
Version 0.1.0 (2026-03-18)
- Initial release
- Basic export functionality with pagination
- Retry logic with configurable delays
- CLI interface
Metadata
Release files for mongoexport 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mongoexport-0.1.4.tar.gz | 5.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mongoexport-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.6 kB
Release files / mongoexport-0.1.4.tar.gz
| Download URL | mongoexport-0.1.4.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6ffdd4ca8af376470db1e1e4f406a18c573c1e71b3da119b340187737985072
|
|
BLAKE2b-256 checksum How to use checksums |
9ebb28f6380114a61b0f10026cd110fee40997b54e77456d53e52aea305f4ccf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.
Transparency logRelease files / mongoexport-0.1.4-py3-none-any.whl
| Download URL | mongoexport-0.1.4-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
418a3e9ff07322349ede5ffd4e8b11c8bb9744776370d0afef8a3de43d32b691
|
|
BLAKE2b-256 checksum How to use checksums |
4b441516f706fc4347bc5e14eaf65d4809444ab82fff3161fb903c77215de7d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 24, 2026.
Transparency log