Last active
December 13, 2015 23:59
-
-
Save garrypolley/4996146 to your computer and use it in GitHub Desktop.
sample mongoengine settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
from mongoengine.connection import connect | |
DB_NAME = os.getenv('MONGO_DB_NAME') or'local-db' | |
DB_HOST = os.getenv('MONGO_DB_HOST') or 'localhost' | |
DB_USER = os.getenv('MONGO_DB_USER') or '' | |
DB_PASS = os.getenv('MONGO_DB_PASSWORD') or '' | |
DB_PORT = os.getenv('MONGO_DB_PORT') or '27017' | |
if DB_USER and DB_PASS: | |
MONGO_CONNECTION = connect(DB_NAME, | |
host='mongodb://{user}:{password}@{host}:{db_port}/{db}'.format(user=DB_USER, | |
host=DB_HOST, | |
password=DB_PASS, | |
db_port=DB_PORT, | |
db=DB_NAME)) | |
else: | |
MONGO_CONNECTION = connect(DB_NAME, host='mongodb://{host}:{db_port}/{db}'.format(host=DB_HOST, | |
db_port=DB_PORT | |
db=DB_NAME) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment