Skip to main content

No project description provided

Project description

joker-mongodb

Example:

GlobalInterface is defined in example/environ.py as:

import volkanic
from joker.mongodb import GIMixinMongo


class GlobalInterface(volkanic.GlobalInterface, GIMixinMongo):
    package_name = 'example'

Configuration file config.json5:

{
    "mongoi": {
        "local": {},
        "remote": {
            "host": "192.168.22.122",
            // default mongo port is 27017
            "port": 27018
        }
    }
}

This config.json5 is at one of the follow locations:

  • Under your project directory in a development enviornment
  • ~/.example/config.json5
  • /etc/example/config.json5
  • /example/config.json5

Usage in code example/application.py:

from bson import ObjectId
from example.environ import GlobalInterface  # noqa

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'))

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

joker-mongodb-0.0.2.tar.gz (18.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page