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
Async database support for Python. 🗄

Databases Databases gives you simple asyncio support for a range of databases. It allows you to make queries using the powerful SQLAlchemy Core expres

Encode 3.2k Dec 30, 2022
Python Wrapper For sqlite3 and aiosqlite

Python Wrapper For sqlite3 and aiosqlite

6 May 30, 2022
New generation PostgreSQL database adapter for the Python programming language

Psycopg 3 -- PostgreSQL database adapter for Python Psycopg 3 is a modern implementation of a PostgreSQL adapter for Python. Installation Quick versio

The Psycopg Team 880 Jan 08, 2023
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
A simple password manager I typed with python using MongoDB .

Python with MongoDB A simple python code example using MongoDB. How do i run this code • First of all you need to have a python on your computer. If y

31 Dec 06, 2022
A HugSQL-inspired database library for Python

PugSQL PugSQL is a simple Python interface for using parameterized SQL, in files. See pugsql.org for the documentation. To install: pip install pugsql

Dan McKinley 558 Dec 24, 2022
An asyncio compatible Redis driver, written purely in Python. This is really just a pet-project for me.

asyncredis An asyncio compatible Redis driver. Just a pet-project. Information asyncredis is, like I've said above, just a pet-project for me. I reall

Vish M 1 Dec 25, 2021
Estoult - a Python toolkit for data mapping with an integrated query builder for SQL databases

Estoult Estoult is a Python toolkit for data mapping with an integrated query builder for SQL databases. It currently supports MySQL, PostgreSQL, and

halcyon[nouveau] 15 Dec 29, 2022
Sample scripts to show extracting details directly from the AIQUM database

Sample scripts to show extracting details directly from the AIQUM database

1 Nov 19, 2021
edaSQL is a library to link SQL to Exploratory Data Analysis and further more in the Data Engineering.

edaSQL is a python library to bridge the SQL with Exploratory Data Analysis where you can connect to the Database and insert the queries. The query results can be passed to the EDA tool which can giv

Tamil Selvan 8 Dec 12, 2022
A pandas-like deferred expression system, with first-class SQL support

Ibis: Python data analysis framework for Hadoop and SQL engines Service Status Documentation Conda packages PyPI Azure Coverage Ibis is a toolbox to b

Ibis Project 2.3k Jan 06, 2023
Query multiple mongoDB database collections easily

leakscoop Perform queries across multiple MongoDB databases and collections, where the field names and the field content structure in each database ma

bagel 5 Jun 24, 2021
Async ODM (Object Document Mapper) for MongoDB based on python type hints

ODMantic Documentation: https://art049.github.io/odmantic/ Asynchronous ODM(Object Document Mapper) for MongoDB based on standard python type hints. I

Arthur Pastel 732 Dec 31, 2022
Asynchronous, fast, pythonic DynamoDB Client

AsyncIO DynamoDB Asynchronous pythonic DynamoDB client; 2x faster than aiobotocore/boto3/botocore. Quick start With httpx Install this library pip ins

HENNGE 48 Dec 18, 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
An extension package of 🤗 Datasets that provides support for executing arbitrary SQL queries on HF datasets

datasets_sql A 🤗 Datasets extension package that provides support for executing arbitrary SQL queries on HF datasets. It uses DuckDB as a SQL engine

Mario Šaško 19 Dec 15, 2022
A Python-based RPC-like toolkit for interfacing with QuestDB.

pykit A Python-based RPC-like toolkit for interfacing with QuestDB. Requirements Python 3.9 Java Azul

QuestDB 11 Aug 03, 2022
Python PostgreSQL database performance insights. Locks, index usage, buffer cache hit ratios, vacuum stats and more.

Python PG Extras Python port of Heroku PG Extras with several additions and improvements. The goal of this project is to provide powerful insights int

Paweł Urbanek 35 Nov 01, 2022
Logica is a logic programming language that compiles to StandardSQL and runs on Google BigQuery.

Logica: language of Big Data Logica is an open source declarative logic programming language for data manipulation. Logica is a successor to Yedalog,

Evgeny Skvortsov 1.5k Dec 30, 2022
MySQL database connector for Python (with Python 3 support)

mysqlclient This project is a fork of MySQLdb1. This project adds Python 3 support and fixed many bugs. PyPI: https://pypi.org/project/mysqlclient/ Gi

PyMySQL 2.2k Dec 25, 2022