Python module for making it easy and consistent to connect to MongoDB via PyMongo either in Flask or in a non-flask application
Project description
Python module for making it easy and consistent to connect to MongoDB via PyMongo either in Flask or in a non-flask application
Usage
config.py as referenced below
MONGO_HOST = 'localhost' MONGO_PORT = '27017' MONGO_USERNAME = 'user' MONGO_PASSWORD = 'password'
Flask
from flask import Flask from happymongo import HapPyMongo # Our apps config.py import config app = Flask(__name__) app.config.from_object(config) mongo, db = HapPyMongo(app)
Python from import
from happymongo import HapPyMongo # Our apps config.py import config mongo, db = HapPyMongo(config)
Python from dict
from happymongo import HapPyMongo config = { 'MONGO_HOST': 'localhost' } mongo, db = HapPyMongo(config)
Config directives
Directive |
Description |
---|---|
MONGO_URI |
A MongoDB URI which is used in preference of the other configuration variables. |
MONGO_HOST |
The host name or IP address of your MongoDB server. Default: “localhost”. |
MONGO_PORT |
The port number of your MongoDB server. Default: 27017. |
MONGO_DATABASE |
The database name to make available as the db attribute. Default: app.name for Flask or the filename of the including file without the .py extension |
MONGO_USERNAME |
The user name for authentication. Default: None |
MONGO_PASSWORD |
The password for authentication. Default: None |
MONGO_KWARGS |
A dictionary of keyword arguments to send to pymongo.MongoClient |
Project details
Release history Release notifications | RSS feed
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
Hashes for happymongo_py3-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00dde879d3001a7b3ac1eb9e70c4988a9331541afebe466c179e41e4e54215a4 |
|
MD5 | de8df7b37004505f511e50b5728a62a7 |
|
BLAKE2b-256 | 8df7661c47d1ac2ad3848f7f3e95b79a599fcf33f92e104362a97ebfe5121628 |