Skip to main content

Export data from MongoDB collections with pagination, delays, and retry logic

Project description

🍃 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/n1nj4t4nuk1/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/n1nj4t4nuk1/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.0 (2026-03-18)

  • Initial release
  • Basic export functionality with pagination
  • Retry logic with configurable delays
  • CLI interface

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mongoexport-0.1.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mongoexport-0.1.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file mongoexport-0.1.3.tar.gz.

File metadata

  • Download URL: mongoexport-0.1.3.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mongoexport-0.1.3.tar.gz
Algorithm Hash digest
SHA256 53fb306bc13b977f0572919e5e00420f04eea6471c07172d4db5e81c3b786a04
MD5 3032887b37c2ffe55b2bf2c5c155b13a
BLAKE2b-256 744839e26fe0cfac8bf8881e5d207a8ad618dda2d9daefdc9557367f1ca39220

See more details on using hashes here.

Provenance

The following attestation bundles were made for mongoexport-0.1.3.tar.gz:

Publisher: publish.yml on n1nj4t4nuk1/mongoexport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mongoexport-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: mongoexport-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mongoexport-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ee00487cc3ebe5755d7c9f2dd4c860d9939e4bfa77a7a62cba1ea163e75a3e77
MD5 c3dae898fb52c49359bdc678f22b63ec
BLAKE2b-256 1ea65513c9c7cda9dac54faa9d2d43441d524cc0ccbe8a7210f52441c64c0fcf

See more details on using hashes here.

Provenance

The following attestation bundles were made for mongoexport-0.1.3-py3-none-any.whl:

Publisher: publish.yml on n1nj4t4nuk1/mongoexport

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page