joker-mongodb
=============
Access mongodb with handy utilities and fun.
Install
-------
From PyPi using `pip`:
python -m pip install joker-mongodb
Link to current virtual environment for development (run at project root directory):
pip install -e .
Python version requirement (plan)
0.5.0 Python 3.7+
0.6.0 Python 3.7+
0.7.0 Python 3.7+
0.8.0 Python 3.8+
0.9.0 Python 3.9+
## Connnect to multiple mongo servers with MongoInterface
Example:
`GlobalInterface` is defined in `example/environ.py` as:
```python
from functools import cached_property
import volkanic
from joker.mongodb.interfaces import MongoInterface
class GlobalInterface(volkanic.GlobalInterface):
package_name = 'example'
default_config = {
"mongoi": {
"local": {},
"remote": {
"host": "192.168.22.122",
"port": 27017
}
}
}
@cached_property
def mongoi(self) -> MongoInterface:
return MongoInterface.from_config(self.conf['mongoi'])
```
If a configuration file is found at one of the follow locations:
- Under your project directory in a development enviornment
- `~/.example/config.json5`
- `/etc/example/config.json5`
- `/example/config.json5`
it will override `GlobalInterface.default_config`.
Usage in code `example/application.py`:
```python
from bson import ObjectId
# noinspection PyUnresolvedReferences,PyPackageRequirements
from example.environ import GlobalInterface
gi = GlobalInterface()
def get_product(product_oid):
coll = gi.mongoi.get_coll('remote', 'example', 'products')
return coll.find_one({'_id': ObjectId(product_oid)})
if __name__ == '__main__':
print(get_product('60f231605e0a4ea3c6c31c13'))
```
Recent changes
--------------
See `docs/changelog.txt`
Raw data
{
"_id": null,
"home_page": "https://github.com/frozflame/joker-mongodb",
"name": "joker-mongodb",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7.0",
"maintainer_email": null,
"keywords": null,
"author": "frozflame",
"author_email": "frozflame@outlook.com",
"download_url": "https://files.pythonhosted.org/packages/03/ed/100cb829ec94fc106a5a3ac3fde9082fb8ae2f83eae7df235522e5b1ba06/joker-mongodb-0.5.2.tar.gz",
"platform": null,
"description": "joker-mongodb\n=============\n\nAccess mongodb with handy utilities and fun.\n\nInstall\n-------\n\nFrom PyPi using `pip`:\n\n python -m pip install joker-mongodb\n\nLink to current virtual environment for development (run at project root directory):\n\n pip install -e .\n\nPython version requirement (plan)\n\n 0.5.0 Python 3.7+\n 0.6.0 Python 3.7+\n 0.7.0 Python 3.7+\n 0.8.0 Python 3.8+\n 0.9.0 Python 3.9+\n\n\n## Connnect to multiple mongo servers with MongoInterface\n\nExample:\n\n`GlobalInterface` is defined in `example/environ.py` as:\n\n```python\nfrom functools import cached_property\n\nimport volkanic\nfrom joker.mongodb.interfaces import MongoInterface\n\n\nclass GlobalInterface(volkanic.GlobalInterface):\n package_name = 'example'\n default_config = {\n \"mongoi\": {\n \"local\": {},\n \"remote\": {\n \"host\": \"192.168.22.122\",\n \"port\": 27017\n }\n }\n }\n\n @cached_property\n def mongoi(self) -> MongoInterface:\n return MongoInterface.from_config(self.conf['mongoi'])\n```\n\nIf a configuration file is found at one of the follow locations:\n\n- Under your project directory in a development enviornment\n- `~/.example/config.json5`\n- `/etc/example/config.json5`\n- `/example/config.json5`\n\nit will override `GlobalInterface.default_config`.\n\nUsage in code `example/application.py`:\n\n```python\nfrom bson import ObjectId\n# noinspection PyUnresolvedReferences,PyPackageRequirements\nfrom example.environ import GlobalInterface\n\ngi = GlobalInterface()\n\n\ndef get_product(product_oid):\n coll = gi.mongoi.get_coll('remote', 'example', 'products')\n return coll.find_one({'_id': ObjectId(product_oid)})\n\n\nif __name__ == '__main__':\n print(get_product('60f231605e0a4ea3c6c31c13'))\n```\n\n\n\n\n\nRecent changes\n--------------\n\nSee `docs/changelog.txt`\n\n",
"bugtrack_url": null,
"license": "GNU General Public License (GPL)",
"summary": "access mongodb with handy utilities and fun",
"version": "0.5.2",
"project_urls": {
"Homepage": "https://github.com/frozflame/joker-mongodb"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "03ed100cb829ec94fc106a5a3ac3fde9082fb8ae2f83eae7df235522e5b1ba06",
"md5": "79672c697b7d7078a8098d1be79ef13d",
"sha256": "158349ddeff9b58ed867a3af860ba7700cd038a32da9eddb6b9a99f2f1ebdd12"
},
"downloads": -1,
"filename": "joker-mongodb-0.5.2.tar.gz",
"has_sig": false,
"md5_digest": "79672c697b7d7078a8098d1be79ef13d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.0",
"size": 32041,
"upload_time": "2024-08-26T07:28:30",
"upload_time_iso_8601": "2024-08-26T07:28:30.235706Z",
"url": "https://files.pythonhosted.org/packages/03/ed/100cb829ec94fc106a5a3ac3fde9082fb8ae2f83eae7df235522e5b1ba06/joker-mongodb-0.5.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-26 07:28:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "frozflame",
"github_project": "joker-mongodb",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "joker-mongodb"
}