skillfed

Flask-PyMongo

PyMongo support for Flask applications

flask-pymongo v3.0.1 228.0K downloads/30d#9,159 on PyPI721
Permissive 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) Active released

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-pymongo

uv

uv add flask-pymongo

poetry

poetry add flask-pymongo

Installing 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

Environment :: Web EnvironmentFramework :: FlaskIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: Software Development :: Libraries :: Python Modules

Tags

flask mongodb integrationpymongo flask extensionmongodb flask ormflask database adaptermongo db connection flaskflask pymongo drivermongodb flask support
flask-extensionmongodb-driverdatabase-integration

More Python Modules packages