Cli tool to interact with mongodb
Project description
mongocat
Cli tool to interact with mongodb
Free software: MIT license
Documentation: https://mongocat.readthedocs.io.
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.
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 Distribution
File details
Details for the file mongocat-0.2.0.tar.gz
.
File metadata
- Download URL: mongocat-0.2.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76cc27f655ed6f83b68d7f5fc6c6685876d5fc67772d4633eb980ac87a663f87 |
|
MD5 | d4b29ced313191ae8e3550dcf1fd388a |
|
BLAKE2b-256 | b2f9fa925333c1f941b1ca3527286589b2f535d0868bb1e78681b3ec14f479d6 |
File details
Details for the file mongocat-0.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: mongocat-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 2, Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1228cef9fac666301dd197ddb165a7b7632e093af1e4d4228b9d8ae47ed3ff35 |
|
MD5 | 2e5c7d7bb44d6cbf97fddb1147986d01 |
|
BLAKE2b-256 | b7d6bbab7fdbd3fffc125eb3262a79a6050740a6ec2606ef3b5c405b057b5b00 |