Skip to main content

MongoDB integration for Bottle

Project description

https://travis-ci.org/bottlepy/bottle-mongo.svg?branch=master

This bottle-mongodb plugin integrates MongoDB with your Bottle application. It injects a MongoDB session in your route and handle the session cycle.

Support pymongo 3 and 2

Usage Example:

from bottle import Bottle ,redirect
from bottle.ext.mongo import MongoPlugin

from bson.json_util import dumps


app = Bottle()
plugin = MongoPlugin(uri="mongodb://127.0.0.1", db="mydb", json_mongo=True)
app.install(plugin)

@app.route('/', method='GET')
def index(mongodb):
    return dumps(mongodb['collection'].find())

@app.route('/create/', method='POST')
def create(mongodb):
    mongodb['collection'].insert({'a': 1, 'b': 2})
    redirect("/")

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

bottle-mongo-0.3.0.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file bottle-mongo-0.3.0.tar.gz.

File metadata

File hashes

Hashes for bottle-mongo-0.3.0.tar.gz
Algorithm Hash digest
SHA256 902bfad1ce40ff592507a717902e2b3f33a436ad14dcbe29d1f50f97bb45450f
MD5 44d6bee6d6b23e5c9849c11e06879a41
BLAKE2b-256 c4b80310a7cfe93b1bedb1c12df1c281ec00d865054eaadeffdbab8b44a05680

See more details on using hashes here.

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