A mongodb aggregate export tool
Project description
maggport
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 a feat accomplished by writing your own shell script or exporting a custom mongodb collection to csv, txt, 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 |
--header | Export with header |
-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
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
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
Built Distributions
File details
Details for the file maggport-1.0.4.tar.gz
.
File metadata
- Download URL: maggport-1.0.4.tar.gz
- Upload date:
- Size: 7.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49a48f2a6f1da3aca118cd8c21df68e1091b886d7a5e11d68701dd6c1eb3464a |
|
MD5 | 97cdc9343fc214bad63815458af3e1e5 |
|
BLAKE2b-256 | f571c8d7ec4ea41420801c37ac502ac608d31d7bd93b6c6023d8c17101cf8e91 |
File details
Details for the file maggport-1.0.4-py3.9.egg
.
File metadata
- Download URL: maggport-1.0.4-py3.9.egg
- Upload date:
- Size: 11.5 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c230eec864a2397ac179ae6400f7d3542e33c30f3288b885c804643c39340b06 |
|
MD5 | 37238d0a1a6676cad04376cfede166c3 |
|
BLAKE2b-256 | 18d8b756c27779b2ed226ad05a199cabfa937d5c92f611748a2afa923cd2808f |
File details
Details for the file maggport-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: maggport-1.0.4-py3-none-any.whl
- Upload date:
- Size: 7.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 834ba4cc6675591a7a54216170f5ceead01bd1a8839fb0264c1c0b105e1e1436 |
|
MD5 | 3a4b641afd043d2b89d4b0f78515a878 |
|
BLAKE2b-256 | 52b9996aeac9facd660dd203195e0f6bba3e16442656a426b0f538bd77cef19a |