Flask-PyMongo
PyMongo support for Flask applications
What it is and what it does
Flask-PyMongo is a Flask extension that wraps PyMongo to simplify MongoDB integration in Flask applications. It initializes a PyMongo instance configured through Flask's app.config, exposing the MongoDB connection and database objects as attributes of the extension object. You configure it with a MONGO_URI connection string and then access collections and perform queries directly through the mongo object in your route handlers and application code.
The package is designed for synchronous Flask applications that need straightforward MongoDB access without additional abstraction layers. It requires Flask 3.0 or later and PyMongo 4.0 or later, and supports Python 3.9 through 3.13 on CPython and PyPy. The extension handles connection lifecycle management within Flask's application context.
Use it for:
- Building Flask web applications that store and retrieve user data, posts, or other documents in MongoDB.
- Querying MongoDB collections directly in Flask route handlers to render dynamic HTML templates.
- Managing MongoDB connections across multiple Flask blueprints and request handlers.
- Prototyping or developing small-to-medium Flask applications with document-oriented data models.
- Integrating MongoDB into existing Flask projects that previously used SQL databases.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Flask-PyMongo integrates MongoDB database access into Flask applications through PyMongo, providing a configured connection object for querying and managing MongoDB collections.
Yes. Flask-PyMongo is actively maintained, has low install friction, carries no known vulnerabilities, and uses a permissive BSD license. Install it if you are building a Flask application that needs MongoDB support and prefer a lightweight, direct integration over an ORM. If you need async support, consider Motor instead.
Install
flask-pymongo on PyPI
pip
pip install flask-pymongouv
uv add flask-pymongopoetry
poetry add flask-pymongoInstalling Flask-PyMongo
Before you install
Low install friction with a pure-Python wheel. Maintenance is active with a recent commit on 2026-08-12 and steady releases; the project has 721 stars and requires flask>=3.0 and pymongo>=4.0.
License in practice
BSD License (permissive). You may use, modify, and distribute this package freely in commercial and private projects, provided you retain the copyright notice and disclaimer.
Quickstart
pip install Flask-PyMongo
from flask import Flask
from flask_pymongo import PyMongo
app = Flask(__name__)
app.config["MONGO_URI"] = "mongodb://localhost:27017/myDatabase"
mongo = PyMongo(app)
users = mongo.db.users.find({"online": True})
Requires a running MongoDB instance accessible at the URI specified in MONGO_URI config.
Verify before relying
- Whether connection pooling and timeout behavior are configurable beyond the MONGO_URI.
- Support for MongoDB Atlas or other cloud-hosted instances beyond local connections.
- Async/await support or whether it is synchronous-only.
Package facts
| License | Copyright (c) 2011-2017, Dan Crosta All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — flask, pymongo |
| Maintenance | actively maintained — 562 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 228,000/month — #9,159 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flask_pymongo-3.0.1-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
pymongoPyMongo is the official MongoDB Python driver,…
permissive · top 1,000 on PyPI
pymongoexplainWraps PyMongo's Collection class to explain…
permissive · top 15,000 on PyPI
djongoDjongo translates Django ORM queries into…
permissive · top 15,000 on PyPI
flask-mongoengineFlask-MongoEngine integrates MongoEngine…
permissive · top 15,000 on PyPI
pymongoarrowPyMongoArrow converts MongoDB query results…
permissive · top 15,000 on PyPI
pymongo_inmemoryProvides an in-memory MongoDB instance for…
permissive · top 15,000 on PyPI
pymongo-auth-awsEnables PyMongo to authenticate to MongoDB…
permissive · top 5,000 on PyPI
pydantic-mongoProvides a Repository pattern for MongoDB with…
permissive · top 15,000 on PyPI
pymongo-search-utilsProvides utility functions for vector search…
permissive · top 15,000 on PyPI
pymongocryptPyMongoCrypt provides Python bindings for…
permissive · top 5,000 on PyPI