Skip to main content

mongocat

https://img.shields.io/pypi/v/mongocat.svg https://img.shields.io/travis/DaniloZZZ/mongocat.svg Documentation Status Updates

Cli tool to interact with mongodb

Overview

Write new documents into collection.

$ export MONGOCAT_URL='mongodb://<username>:<password>@your-mongo-host'
$ mongocat -W -d tensim graphs
foo: bar                                # enter your object in minified yaml
5ec0a27324ec53bd2464c074                # prints object id on success
foo: baz
5ec0a27a24ec53bd2464c075

Read documents from a collection

$ mongocat -R -d tensim graphs
{'_id': ObjectId('5ec0a27324ec53bd2464c074'), 'foo': 'bar'}
{'_id': ObjectId('5ec0a27a24ec53bd2464c075'), 'foo': 'baz'}

Usage

$ mongocat --help
Usage: mongocat [OPTIONS] COLLECTION

  Read/write to mongodb COLLECTION.

Options:
  -R, --read
  -W, --write
  -p, --parser [json|yaml]
  -u, --url TEXT            MongoDB URI. format:
                            mongodb://[username:password@]host1[:port1]...

  -d, --database TEXT       Database name
  --help                    Show this message and exit.

Combine with the power of unix

Dump running processes to db

$ ps | jc --ps | jq -cM '.[]' | mongocat -WR -d tensim processes
5ec0aeef4814de15eb742155
5ec0aeef4814de15eb742156
5ec0aeef4814de15eb742157
5ec0aeef4814de15eb742158
5ec0aeef4814de15eb742159
{'_id': ObjectId('5ec0aeef4814de15eb742155'), 'pid': 195657, 'tty': 'pts/8', 'time': '00:01:05', 'cmd': 'fish'}
{'_id': ObjectId('5ec0aeef4814de15eb742156'), 'pid': 396223, 'tty': 'pts/8', 'time': '00:00:00', 'cmd': 'ps'}
{'_id': ObjectId('5ec0aeef4814de15eb742157'), 'pid': 396224, 'tty': 'pts/8', 'time': '00:00:00', 'cmd': 'jc'}
{'_id': ObjectId('5ec0aeef4814de15eb742158'), 'pid': 396225, 'tty': 'pts/8', 'time': '00:00:00', 'cmd': 'jq'}
{'_id': ObjectId('5ec0aeef4814de15eb742159'), 'pid': 396226, 'tty': 'pts/8', 'time': '00:00:00', 'cmd': 'mongocat'}

Curl straight into DB

$ curl 'https://api.github.com/repos/DaniloZZZ/mongocat/commits?per_page=5' |\
 jq -cM '.[] | {msg: .commit.message, name: .commit.committer.name}' |\
 mongocat -WR -d tensim commits
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                                                 Dload  Upload   Total   Spent    Left  Speed
100 11145  100 11145    0     0  47628      0 --:--:-- --:--:-- --:--:-- 47628
5ec0aa4ac6ddf6dc2bf2def9
5ec0aa4ac6ddf6dc2bf2defa
5ec0aa4ac6ddf6dc2bf2defb
{'_id': ObjectId('5ec0aa4ac6ddf6dc2bf2def9'), 'msg': 'First working version', 'name': 'Danil Lykov'}
{'_id': ObjectId('5ec0aa4ac6ddf6dc2bf2defa'), 'msg': 'upd deps', 'name': 'Danil Lykov'}
{'_id': ObjectId('5ec0aa4ac6ddf6dc2bf2defb'), 'msg': 'init', 'name': 'Danil Lykov'}
Tools used:

TODO

  • [ ] Option to suppress print of added document

  • [ ] Finding command that filters documents aka mongo grep

  • [ ] Deleting documens using ids from stdin. Delete some: mongocat --find 'blah' | mongocat --delete

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2020-05-16)

  • First release on PyPI.

Metadata

Release files for mongocat 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mongocat 0.2.1
File Size Uploaded Provenance Actions
mongocat-0.2.1.tar.gz 12.8 kB Without provenance Details for mongocat-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mongocat 0.2.1
File Interpreter ABI Platform Actions
mongocat-0.2.1-py2.py3-none-any.whl Python 3, Python 2 none any Details for mongocat-0.2.1-py2.py3-none-any.whl

Total release size: 18.8 kB

Release files / mongocat-0.2.1.tar.gz

Download URL mongocat-0.2.1.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
92f07597f9b9ef495f6490aaa8b20e7ee9e774b7abf784e8cfe992394e7fdc33
BLAKE2b-256 checksum
How to use checksums
8eacbead516bc9e35e2f7260c8014c5024b1a9b1cbb7d4c7f70b960312be1eda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Release files / mongocat-0.2.1-py2.py3-none-any.whl

Download URL mongocat-0.2.1-py2.py3-none-any.whl
Size 6.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f2d14c759c1da6e8dc5dae611a169e1872428b6ee66e795d7206d3881eb6986b
BLAKE2b-256 checksum
How to use checksums
71e949e1fd78be8c5e343cd7b2d94bbc89f1443341f9e9be4d64c0372a9e71ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Security for mongocat 0.2.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page