https://github.com/bottlepy/bottle-mongo
https://github.com/bottlepy/bottle-mongo
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/bottlepy/bottle-mongo
- Owner: bottlepy
- Created: 2014-03-11T16:34:15.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2023-01-18T09:22:45.000Z (over 3 years ago)
- Last Synced: 2025-04-10T00:28:33.648Z (about 1 year ago)
- Language: Python
- Size: 17.6 KB
- Stars: 30
- Watchers: 8
- Forks: 9
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
Bottle MongoDB
==============
.. image:: https://travis-ci.org/bottlepy/bottle-mongo.svg?branch=master
:target: https://travis-ci.org/bottlepy/bottle-mongo
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:
.. code-block:: python
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("/")