<commit_before>Flask-PyMongo
=============

`MongoDB <http://www.mongodb.org/>`_ is an open source database that stores
flexible JSON-like "documents," which can have any number, name, or
hierarchy of fields within, instead of rows of data as in a relational
database. Python developers can think of MongoDB as a persistent, searchable
repository of Python dictionaries (and, in fact, this is how `PyMongo
<http://api.mongodb.org/python/current/>`_ represents MongoDB documents).

Flask-PyMongo bridges Flask and PyMongo, so that you can use Flask's normal
mechanisms to configure and connect to MongoDB.


Quickstart
----------

First, install Flask-PyMongo:

.. code-block:: bash

    $ pip install Flask-PyMongo

Flask-PyMongo depends, and will install for you, recent versions of Flask
(0.8 or later) and PyMongo (2.4 or later).

Next, add a :class:`~flask_pymongo.PyMongo` to your code:

.. code-block:: python

    from flask import Flask
    from flask.ext.pymongo import PyMongo

    app = Flask(__name__)
    mongo = PyMongo(app)

:class:`~flask_pymongo.PyMongo` connects to the MongoDB server running on
port 27017 on localhost, and assumes a default database name of ``app.name``
(i.e. whatever name you pass to :class:`~flask.Flask`). This database is
exposed as the :attr:`~flask_pymongo.PyMongo.db` attribute.

You can use :attr:`~flask_pymongo.PyMongo.db` directly in views:

.. code-block:: python

    @app.route('/')
    def home_page():<commit_msg>add compatible python versions to docs<commit_after>Flask-PyMongo
=============

`MongoDB <http://www.mongodb.org/>`_ is an open source database that stores
flexible JSON-like "documents," which can have any number, name, or
hierarchy of fields within, instead of rows of data as in a relational
database. Python developers can think of MongoDB as a persistent, searchable
repository of Python dictionaries (and, in fact, this is how `PyMongo
<http://api.mongodb.org/python/current/>`_ represents MongoDB documents).

Flask-PyMongo bridges Flask and PyMongo, so that you can use Flask's normal
mechanisms to configure and connect to MongoDB.


Quickstart
----------

First, install Flask-PyMongo:

.. code-block:: bash

    $ pip install Flask-PyMongo

Flask-PyMongo depends, and will install for you, recent versions of Flask
(0.8 or later) and PyMongo (2.4 or later). Flask-PyMongo is compatible
with and tested on Python 2.6, 2.7, and 3.3.

Next, add a :class:`~flask_pymongo.PyMongo` to your code:

.. code-block:: python

    from flask import Flask
    from flask.ext.pymongo import PyMongo

    app = Flask(__name__)
    mongo = PyMongo(app)

:class:`~flask_pymongo.PyMongo` connects to the MongoDB server running on
port 27017 on localhost, and assumes a default database name of ``app.name``
(i.e. whatever name you pass to :class:`~flask.Flask`). This database is
exposed as the :attr:`~flask_pymongo.PyMongo.db` attribute.

You can use :attr:`~flask_pymongo.PyMongo.db` directly in views:

.. code-block:: python

    @app.route('/')
    def home_page():
{'fraction_non_alphanumeric': 0.1091688654353562, 'fraction_numerical': 0.0079155672823219, 'mean_word_length': 4.131979695431472, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6667402', 'n_tokens_mistral': 1015, 'n_tokens_neox': 956, 'n_words': 364}