talira

MongoDB's official Python driver, with sync and async APIs

open sourceApache-2.0free

PyMongo is MongoDB's official Python driver. The distribution has three packages: pymongo, a native driver for MongoDB with synchronous and asynchronous APIs; bson, its implementation of the BSON format; and gridfs, for storing large files in MongoDB. It supports MongoDB 4.4 through 9.0, follows semantic versioning, and has optional extras for mongodb+srv URIs, GSSAPI and AWS authentication, OCSP, wire compression and client-side field level encryption.

Problems it solves

  • connect my Python app to a MongoDB database
  • query MongoDB from asyncio code without a separate async driver
  • store large files in MongoDB from Python

Features

  • synchronous and asynchronous APIs
  • bson package for the BSON format
  • GridFS for large files
  • supports MongoDB 4.4 to 9.0
  • optional extras for SRV URIs, GSSAPI and AWS auth, OCSP, compression and client-side field level encryption

Limitations

  • It ships its own bson package, so the unrelated bson package on PyPI must not be installed alongside it.1
  • Needs CPython 3.11 or later.1

Alternatives

The same job

These do what PyMongo does.

  1. redis-py The official Python client for Redis

Compare PyMongo with the top 3