Skip to main content

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:

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:

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

Metadata

Release files for joker-mongodb 0.5.2

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

Source distribution (sdist)

Source distribution for joker-mongodb 0.5.2
File Size Uploaded
joker-mongodb-0.5.2.tar.gz 32.0 kB Details

Release files / joker-mongodb-0.5.2.tar.gz

Download URL joker-mongodb-0.5.2.tar.gz
Size 32.0 kB
Tags Source
SHA-256 checksum
How to use checksums
158349ddeff9b58ed867a3af860ba7700cd038a32da9eddb6b9a99f2f1ebdd12
BLAKE2b-256 checksum
How to use checksums
03ed100cb829ec94fc106a5a3ac3fde9082fb8ae2f83eae7df235522e5b1ba06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.14

Release history Release notifications | RSS feed

This release

0.5.2 This release

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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