Motor - the async Python driver for MongoDB and Tornado or asyncio

Related tags

Database Driversmotor
Overview

Motor

https://raw.github.com/mongodb/motor/master/doc/_static/motor.png

Info: Motor is a full-featured, non-blocking MongoDB driver for Python Tornado and asyncio applications.
Documentation: Available at motor.readthedocs.io
Author: A. Jesse Jiryu Davis

About

Motor presents a coroutine-based API for non-blocking access to MongoDB. The source is on GitHub and the docs are on ReadTheDocs.

"We use Motor in high throughput environments, processing tens of thousands of requests per second. It allows us to take full advantage of modern hardware, ensuring we utilise the entire capacity of our purchased CPUs. This helps us be more efficient with computing power, compute spend and minimises the environmental impact of our infrastructure as a result."

David Mytton, Server Density

"We develop easy-to-use sensors and sensor systems with open source software to ensure every innovator, from school child to laboratory researcher, has the same opportunity to create. We integrate Motor into our software to guarantee massively scalable sensor systems for everyone."

Ryan Smith, inXus Interactive

Support / Feedback

For issues with, questions about, or feedback for PyMongo, please look into our support channels. Please do not email any of the Motor developers directly with issues or questions - you're more likely to get an answer on the MongoDB Community Forums.

Bugs / Feature Requests

Think you've found a bug? Want to see a new feature in Motor? Please open a case in our issue management tool, JIRA:

Bug reports in JIRA for all driver projects (i.e. MOTOR, CSHARP, JAVA) and the Core Server (i.e. SERVER) project are public.

How To Ask For Help

Please include all of the following information when opening an issue:

  • Detailed steps to reproduce the problem, including full traceback, if possible.

  • The exact python version used, with patch level:

    $ python -c "import sys; print(sys.version)"
    
  • The exact version of Motor used, with patch level:

    $ python -c "import motor; print(motor.version)"
    
  • The exact version of PyMongo used, with patch level:

    $ python -c "import pymongo; print(pymongo.version); print(pymongo.has_c())"
    
  • The exact Tornado version, if you are using Tornado:

    $ python -c "import tornado; print(tornado.version)"
    
  • The operating system and version (e.g. RedHat Enterprise Linux 6.4, OSX 10.9.5, ...)

Security Vulnerabilities

If you've identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here.

Installation

Motor can be installed with pip:

$ pip install motor

Dependencies

Motor works in all the environments officially supported by Tornado or by asyncio. It requires:

  • Unix (including macOS) or Windows.
  • PyMongo >=3.11,<4
  • Python 3.5+

See requirements for details about compatibility.

Examples

See the examples on ReadTheDocs.

Documentation

Motor's documentation is on ReadTheDocs.

Build the documentation with Python 3.5. Install sphinx, Tornado, and aiohttp, and do cd doc; make html.

Testing

Run python setup.py test. Tests are located in the test/ directory.

Comments
  • MOTOR-40 Example using aiohttp.

    MOTOR-40 Example using aiohttp.

    @asvetlov, thanks to you and @jettify, Motor 0.5 with asyncio is close to release. Could you review this example application that I plan to include in the tutorial?

    The docs are rendered here:

    http://emptysqua.re/aiotthp-example-docs/tutorial-asyncio.html#a-web-application-with-aiohttp

    Review on Reviewable

    opened by ajdavis 11
  • MOTOR-979 Use asyncio.get_event_loop so that DeprecationWarnings are correctly issued

    MOTOR-979 Use asyncio.get_event_loop so that DeprecationWarnings are correctly issued

    …issued

    It looks like a workaround I wrote in Tornado was incorrectly incorporated into AsyncioMotorClient here https://github.com/mongodb/motor/pull/155/files#r851429040

    if a user has opted into DeprecationWarnings as errors asyncio.get_event_loop_policy().get_event_loop() incorrectly suppresses the deprecation warning:

    Python 3.10.4 (main, Apr  8 2022, 17:35:13) [GCC 9.4.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import motor.motor_asyncio
    >>> client = motor.motor_asyncio.AsyncIOMotorClient()
    >>> client.test.pages.drop()  # this should raise a DeprecationWarning because it was called without a running loop
    <Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/lib/python3.10/asyncio/futures.py:384]>
    >>> 
    
    opened by graingert 8
  • MotorCursor().to_list applies outgoing_son_manipulators as expected

    MotorCursor().to_list applies outgoing_son_manipulators as expected

    • added MotorDatabase()._fix_outgoing calling the delegate's method since we call add_son_manipulator on the delegate as well.
    • applying _fix_outgoing when to_list retrieves data from Cursor's deque
    • tests for to_list and control find_one, next_object (these two were unaffected by this bug)
    opened by eguven 7
  • MOTOR-884 Mirror all PyMongo extras

    MOTOR-884 Mirror all PyMongo extras

    Motor is a wrapper around Pymongo, extras available during pip install Pymongo should be available with Motor as well. I recently faced an issue regarding this and have raised it on Jira.

    opened by tusharsnn 5
  • Add 'mongo_client' argument to AgnosticClient

    Add 'mongo_client' argument to AgnosticClient

    This change adds a new mongo_client argument when creating a new MotorClient or AsyncIOMotorClient instance, setting the delegate object to a pre-existing MongoClient instead of creating a new instance.

    Background

    I help maintain a project that uses Motor and has a very large number of tests, the majority of which involve MongoDB accesses. These tests use Tornado's AsyncTestCase and create new MotorClient instances in their setUp methods. As the tests run, they become progressively slower and, especially on weaker computers, eventually hang. Attaching a debugger to the hung Python process shows that there are a large number of active threads, the number roughly corresponding to the number of MotorClient instances that were created, thus far. These threads appear to be running the PyMongo _process_periodic_tasks code run through the periodic executor.

    To avoid the hanging issue and improve overall test performance, we would like to be able to re-use the same MotorClient instance in all tests that need database access but, since MotorClient needs an IO loop and Tornado's AsyncTestCase creates a new IO loop for each test, that does not appear possible. A decent alternative is to re-use a single MongoClient instance for all tests and pass that MongoClient when creating a new MotorClient in the setUp method.

    opened by tjensen 5
  • Add optional dependencies, forwarding them to pymongo

    Add optional dependencies, forwarding them to pymongo

    pymongo supports three optional dependencies, it would be nice to support them as well here, so that we can depend directly on motor[srv] instead of having to list both motor and pymongo[srv]

    opened by arthurdarcet 4
  • MOTOR-1014 Add __aenter__ and __aexit__ for AgnosticBaseCursor so that cursor can be instantiated using the context manager

    MOTOR-1014 Add __aenter__ and __aexit__ for AgnosticBaseCursor so that cursor can be instantiated using the context manager

    When I use the following code:

    async with self.coll.find() as cursor:
        async for record in cursor:
            yield record
    

    It's going to throw an AttributeError So I added the asynchronous context manager method so that I did not have to close the cursor when I was done with it

    opened by coderk17 3
Releases(3.1.1)
  • 3.1.1(Oct 25, 2022)

  • 3.1.0(Sep 13, 2022)

  • 3.0.0(Apr 28, 2022)

  • 2.5.1(Aug 19, 2021)

  • 2.4.0(Apr 8, 2021)

    Motor 2.4 adds support for client-side field-level encryption and Python 3.9.

    For more info see the changelog: https://motor.readthedocs.io/en/2.4.0/changelog.html

    Source code(tar.gz)
    Source code(zip)
  • 2.3.0(Sep 24, 2020)

  • 2.2.0(Aug 14, 2020)

    Motor 2.2 adds support for MongoDB 4.4 features. It depends on PyMongo 3.11 or later. Motor continues to support MongoDB 3.0 and later. Motor 2.2 also drops support for Python 2.7 and Python 3.4.

    For more info see the changelog: https://motor.readthedocs.io/en/2.2.0/changelog.html

    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Dec 12, 2019)

    Motor 2.1 adds support for MongoDB 4.2 features. It depends on PyMongo 3.10 or later. Motor continues to support MongoDB 3.0 and later. Motor 2.1 also adds support for Python 3.8.

    Motor now offers experimental support for Windows when it is using the asyncio event loop. This means it supports Windows exclusively with Python 3, either integrating with asyncio directly or with Tornado 5 or later: starting in version 5, Tornado uses the asyncio event loop on Python 3 by default.

    For more info see the changelog: https://motor.readthedocs.io/en/2.1.0/changelog.html

    Source code(tar.gz)
    Source code(zip)
Owner
mongodb
mongodb
SAP HANA Connector in pure Python

SAP HANA Database Client for Python Important Notice This public repository is read-only and no longer maintained. The active maintained alternative i

SAP Archive 299 Nov 20, 2022
Application which allows you to make PostgreSQL databases with Python

Automate PostgreSQL Databases with Python Application which allows you to make PostgreSQL databases with Python I used the psycopg2 library which is u

Marc-Alistair Coffi 0 Dec 31, 2021
Py2neo is a comprehensive toolkit for working with Neo4j from within Python applications or from the command line.

Py2neo Py2neo is a client library and toolkit for working with Neo4j from within Python applications and from the command line. The library supports b

Nigel Small 1.2k Jan 02, 2023
Simple Python demo app that connects to an Oracle DB.

Cloud Foundry Sample Python Application Connecting to Oracle Simple Python demo app that connects to an Oracle DB. The app is based on the example pro

Daniel Buchko 1 Jan 10, 2022
Py2neo is a comprehensive toolkit for working with Neo4j from within Python applications or from the command line.

Py2neo v3 Py2neo is a client library and toolkit for working with Neo4j from within Python applications and from the command line. The core library ha

64 Oct 14, 2022
A fast unobtrusive MongoDB ODM for Python.

MongoFrames MongoFrames is a fast unobtrusive MongoDB ODM for Python designed to fit into a workflow not dictate one. Documentation is available at Mo

getme 45 Jun 01, 2022
Python client for InfluxDB

InfluxDB-Python InfluxDB-Python is a client for interacting with InfluxDB. Development of this library is maintained by: Github ID URL @aviau (https:/

InfluxData 1.6k Dec 24, 2022
SQL for Humans™

Records: SQL for Humans™ Records is a very simple, but powerful, library for making raw SQL queries to most relational databases. Just write SQL. No b

Ken Reitz 6.9k Jan 03, 2023
Pystackql - Python wrapper for StackQL

pystackql - Python Library for StackQL Python wrapper for StackQL Usage from pys

StackQL Studios 6 Jul 01, 2022
Confluent's Kafka Python Client

Confluent's Python Client for Apache KafkaTM confluent-kafka-python provides a high-level Producer, Consumer and AdminClient compatible with all Apach

Confluent Inc. 3.1k Jan 05, 2023
MinIO Client SDK for Python

MinIO Python SDK for Amazon S3 Compatible Cloud Storage MinIO Python SDK is Simple Storage Service (aka S3) client to perform bucket and object operat

High Performance, Kubernetes Native Object Storage 582 Dec 28, 2022
Creating a python package to convert /transfer excelsheet data to a mysql Database Table

Creating a python package to convert /transfer excelsheet data to a mysql Database Table

Odiwuor Lameck 1 Jan 07, 2022
MySQL Operator for Kubernetes

MySQL Operator for Kubernetes The MYSQL Operator for Kubernetes is an Operator for Kubernetes managing MySQL InnoDB Cluster setups inside a Kubernetes

MySQL 462 Dec 24, 2022
Amazon S3 Transfer Manager for Python

s3transfer - An Amazon S3 Transfer Manager for Python S3transfer is a Python library for managing Amazon S3 transfers. Note This project is not curren

the boto project 158 Jan 07, 2023
Python DBAPI simplified

Facata A Python library that provides a simplified alternative to DBAPI 2. It provides a facade in front of DBAPI 2 drivers. Table of Contents Install

Tony Locke 44 Nov 17, 2021
Little wrapper around asyncpg for specific experience.

Little wrapper around asyncpg for specific experience.

Nikita Sivakov 3 Nov 15, 2021
Databank is an easy-to-use Python library for making raw SQL queries in a multi-threaded environment.

Databank Databank is an easy-to-use Python library for making raw SQL queries in a multi-threaded environment. No ORM, no frills. Thread-safe. Only ra

snapADDY GmbH 4 Apr 04, 2022
Asynchronous interface for peewee ORM powered by asyncio

peewee-async Asynchronous interface for peewee ORM powered by asyncio. Important notes Since version 0.6.0a only peewee 3.5+ is supported If you still

05Bit 666 Dec 30, 2022
A wrapper around asyncpg for use with sqlalchemy

asyncpgsa A python library wrapper around asyncpg for use with sqlalchemy Backwards incompatibility notice Since this library is still in pre 1.0 worl

Canopy 404 Dec 03, 2022
Pandas Google BigQuery

pandas-gbq pandas-gbq is a package providing an interface to the Google BigQuery API from pandas Installation Install latest release version via conda

Python for Data 345 Dec 28, 2022