shaypal5 / mongozen

Enhance MongoDB for Python dynamic shells and scripts.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mongozen

PyPI-Status PyPI-Versions Build-Status Codecov LICENCE

MongoDB utilities for Python.

from mongozen.util import export_collection
export_collection(collection_obj, '~/dump.json')
pip install mongozen

mongozen is divided into three sub-packages, by functionality:

Defines a Matchop class representing a pymongo matching operator. It extends the standard Python dict, provides a smart representation of a MongoDB matching operator with well-defined and optimized & and | operators. For example:

from mongozen.matchop import Matchop
match_dateint = Matchop({'dateInt': {'$gt': 20161203}})
match_dateint_and_id = match_dateint & {'user_id': 12}
print(match_dateint_and_id)

will output

{'user_id': 12, 'dateInt': {'$gt': 20161203}}

While

match_dateint = Matchop({'dateInt': {'$gt': 20161203}})
match_dateint_updated = match_dateint & {'dateInt': {'$gt': 20161208}}
print(match_dateint_updated)

will output

{ {'dateInt': {'$gt': 20161208}} }

Contains some usefull queries.

Contains utility functions, like Python wrappers for MongoDB command-line tools.

Package author and current maintainer is Shay Palachy (shay.palachy@gmail.com); You are more than welcome to approach him for help. Contributions are very welcomed.

Clone:

git clone git@github.com:shaypal5/mongozen.git

Install in development mode:

cd mongozen
pip install -e .[test]
# or, if you use pipenv
pipenv install --dev

To run the tests use:

pytest
# or, if you use pipenv
pipenv run pytest

The project is documented using the numpy docstring conventions, which were chosen as they are perhaps the most widely-spread conventions that are both supported by common tools such as Sphinx and result in human-readable docstrings. When documenting code you add to this project, follow these conventions.

Additionally, if you update this README.rst file, use python setup.py checkdocs (or pipenv run the same command) to validate it compiles.

Created by Shay Palachy (shay.palachy@gmail.com).

About

Enhance MongoDB for Python dynamic shells and scripts.

License:MIT License


Languages

Language:Python 100.0%