Skip to main content

A mongodb aggregate export tool

Project description

maggport

Coverage Report pre-commit security: bandit Imports: isort Code style: black

A mongodb aggregate export CLI tool

Overview

maggport is a python CLI tool designed to bridge the gap of exporting aggregate pipeline(s) in mongodb. What used to be feat accomplished by writing your own shell script or exporting a custom mongodb collection to csv or JSON, generated by running an aggregate pipeline, can now be achieved by this tool.

Installation

pip install maggport

Usage

Arguments Description
-c/--collection Collection of database
-d/--db Database to connect
-h/--host Hostname of mongodb instance
--no-allow-disk-use Don't allow disk use
-o/--out Output file
-p/--port Port of mongodb instance
-q/--pipeline Pipeline to run
-f/--pipeline-path Path of pipeline if saved in file

host: sample_host
port: 8080
db: food
collection: fruits

[
    {
        "name": "apple",
        "origin":  "usa",
        "price": 5
    },
    {
        "name": "apple",
        "origin":  "italy",
        "price": 4
    },
    {
        "name": "apple",
        "origin":  "philippines",
        "price": 3
    },
    {
        "name": "mango",
        "origin":  "malaysia",
        "price": 3
    }
]

Example 1

Passing pipeline as a parameter and output results in terminal.

maggport --host sample_host --port 8080 --db food --collection fruits --pipeline '[{"$group": {"_id": "$name", "count": {"$sum": 1}}}, {"$match": {"count": {"$gt": 1}}}]'

Output:

[
    {
        "_id":"apple",
        "count": 3
    }
]

Example 2

Passing pipeline as a file and output results in terminal.

pipeline.txt

[
    {"$group": {"_id": "$name", "count": {"$sum": 1}}},
    {"$match": {"count": {"$gt": 1}}}
]
maggport --host sample_host --port 8080 --db food --collection fruits --pipeline-path pipeline.txt

Output:

[
    {
        "_id":"apple",
        "count": 3
    }
]

Example 3

Export results as csv file.

pipeline.txt

[
    {"$group": {"_id": "$name", "count": {"$sum": 1}}},
    {"$match": {"count": {"$gt": 1}}}
]
maggport --host sample_host --port 8080 --db food --collection fruits --pipeline-path pipeline.txt --out test_results.csv

Output:

test_results.csv

image

Bugs/Request

Please submit an issue in GitHub

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue in the maggport dashboard, or any other method with the owner(s)(info at the bottom of this README) of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

For more information about how to contribute, take a look at CONTRIBUTE.md

Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4

Maintainers

@ccavales3

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

maggport-1.0.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

maggport-1.0.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file maggport-1.0.2.tar.gz.

File metadata

  • Download URL: maggport-1.0.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for maggport-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ee3a2f123587b8c218c4be3b83b31ad2be6a485ac258cfd4554ed2a35481f849
MD5 24858071e8a73b0259555956fc6d18bf
BLAKE2b-256 d2e29eca1784bc5e6551270409d60f51a50832ded8a6d8f21b84e7574d459c90

See more details on using hashes here.

File details

Details for the file maggport-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: maggport-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for maggport-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a52bcc447bdc443f3a1b0770e5398de444c07a0326b569b37954a3057efeb74a
MD5 ed536684c382201d699fc5ba6f9a3dfb
BLAKE2b-256 0be426430f6574c003d5f7c7546f1316133db19b534b1fe21bdbb2260d28a7dc

See more details on using hashes here.

Supported by

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