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/yourusername/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/yourusername/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.2.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.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mongoexport-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 2cea4cd423b5b1348d7905a0a43e94080c65ff29d7b985e8d79bd5fbfed078f4
MD5 f4dd4eb34fef3330bbd2d21dd910c9be
BLAKE2b-256 3ccbe1546182c0becafe5b14508d6f787c80cc134cc5f6122c5435d59a61d9a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for mongoexport-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: mongoexport-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d4072296f1e73c9584e17e5d5e0340571560712e1e41d93b1f64f4b996c417d1
MD5 396c76a66a8dbb6ef9680737b4d63e23
BLAKE2b-256 a477bad820fdcdd3bcca9b36c3e8286cbcc7ef797702d058124950a1100df3ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for mongoexport-0.1.2-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