Motor: Asynchronous Python driver for MongoDB¶
About¶
Motor presents a coroutine-based API for non-blocking access to MongoDB from Tornado or asyncio.
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
Install with:
$ python -m pip install motor
Getting Help¶
If you’re having trouble or have questions about Motor, ask your question on our MongoDB Community Forum. You may also want to consider a commercial support subscription. Once you get an answer, it’d be great if you could work it back into this documentation and contribute!
Issues¶
All issues should be reported (and can be tracked / voted for / commented on) at the main MongoDB JIRA bug tracker, in the “Motor” project.
Feature Requests / Feedback¶
Use our feedback engine to send us feature requests and general feedback about PyMongo.
Contributing¶
Motor has a large community and contributions are always encouraged. Contributions can be as simple as minor tweaks to this documentation. To contribute, fork the project on GitHub and send a pull request.
Changes¶
See the Changelog for a full list of changes to Motor.
Contents¶
Classes¶
- Motor Tornado API
MotorClient
– Connection to MongoDBMotorClient
MotorClient.drop_database()
MotorClient.get_database()
MotorClient.get_default_database()
MotorClient.list_database_names()
MotorClient.list_databases()
MotorClient.server_info()
MotorClient.start_session()
MotorClient.watch()
MotorClient.HOST
MotorClient.PORT
MotorClient.address
MotorClient.arbiters
MotorClient.close
MotorClient.codec_options
MotorClient.is_mongos
MotorClient.is_primary
MotorClient.nodes
MotorClient.options
MotorClient.primary
MotorClient.read_concern
MotorClient.read_preference
MotorClient.secondaries
MotorClient.topology_description
MotorClient.write_concern
MotorClientSession
– Sequence of operationsMotorClientSession
MotorClientSession.abort_transaction()
MotorClientSession.commit_transaction()
MotorClientSession.end_session()
MotorClientSession.start_transaction()
MotorClientSession.with_transaction()
MotorClientSession.advance_cluster_time
MotorClientSession.advance_operation_time
MotorClientSession.client
MotorClientSession.cluster_time
MotorClientSession.has_ended
MotorClientSession.in_transaction
MotorClientSession.operation_time
MotorClientSession.options
MotorClientSession.session_id
MotorDatabase
MotorDatabase
MotorDatabase.aggregate()
MotorDatabase.command()
MotorDatabase.create_collection()
MotorDatabase.cursor_command()
MotorDatabase.dereference()
MotorDatabase.drop_collection()
MotorDatabase.get_collection()
MotorDatabase.list_collection_names()
MotorDatabase.list_collections()
MotorDatabase.validate_collection()
MotorDatabase.watch()
MotorDatabase.with_options()
MotorDatabase.client
MotorDatabase.codec_options
MotorDatabase.name
MotorDatabase.read_concern
MotorDatabase.read_preference
MotorDatabase.write_concern
MotorCollection
MotorCollection
MotorCollection.database
MotorCollection.aggregate()
MotorCollection.aggregate_raw_batches()
MotorCollection.bulk_write()
MotorCollection.count_documents()
MotorCollection.create_index()
MotorCollection.create_indexes()
MotorCollection.create_search_index()
MotorCollection.create_search_indexes()
MotorCollection.delete_many()
MotorCollection.delete_one()
MotorCollection.distinct()
MotorCollection.drop()
MotorCollection.drop_index()
MotorCollection.drop_indexes()
MotorCollection.drop_search_index()
MotorCollection.estimated_document_count()
MotorCollection.find()
MotorCollection.find_one()
MotorCollection.find_one_and_delete()
MotorCollection.find_one_and_replace()
MotorCollection.find_one_and_update()
MotorCollection.find_raw_batches()
MotorCollection.index_information()
MotorCollection.insert_many()
MotorCollection.insert_one()
MotorCollection.list_indexes()
MotorCollection.list_search_indexes()
MotorCollection.options()
MotorCollection.rename()
MotorCollection.replace_one()
MotorCollection.update_many()
MotorCollection.update_one()
MotorCollection.update_search_index()
MotorCollection.watch()
MotorCollection.with_options()
MotorCollection.codec_options
MotorCollection.full_name
MotorCollection.name
MotorCollection.read_concern
MotorCollection.read_preference
MotorCollection.write_concern
MotorChangeStream
MotorClientEncryption
MotorClientEncryption
MotorClientEncryption.add_key_alt_name()
MotorClientEncryption.close()
MotorClientEncryption.create_data_key()
MotorClientEncryption.create_encrypted_collection()
MotorClientEncryption.decrypt()
MotorClientEncryption.delete_key()
MotorClientEncryption.encrypt()
MotorClientEncryption.encrypt_expression()
MotorClientEncryption.get_key()
MotorClientEncryption.get_key_by_alt_name()
MotorClientEncryption.remove_key_alt_name()
MotorClientEncryption.rewrap_many_data_key()
MotorCursor
MotorCursor
MotorCursor.add_option()
MotorCursor.allow_disk_use()
MotorCursor.clone()
MotorCursor.close()
MotorCursor.collation()
MotorCursor.comment()
MotorCursor.distinct()
MotorCursor.each()
MotorCursor.explain()
MotorCursor.hint()
MotorCursor.limit()
MotorCursor.max()
MotorCursor.max_await_time_ms()
MotorCursor.max_scan()
MotorCursor.max_time_ms()
MotorCursor.min()
MotorCursor.next()
MotorCursor.next_object()
MotorCursor.remove_option()
MotorCursor.rewind()
MotorCursor.skip()
MotorCursor.sort()
MotorCursor.to_list()
MotorCursor.where()
MotorCursor.address
MotorCursor.alive
MotorCursor.cursor_id
MotorCursor.fetch_next
MotorCursor.session
MotorCommandCursor
MotorCommandCursor
MotorCommandCursor.close()
MotorCommandCursor.each()
MotorCommandCursor.next()
MotorCommandCursor.next_object()
MotorCommandCursor.to_list()
MotorCommandCursor.try_next()
MotorCommandCursor.address
MotorCommandCursor.alive
MotorCommandCursor.cursor_id
MotorCommandCursor.fetch_next
MotorCommandCursor.session
- Motor GridFS Classes
MotorGridFSBucket
MotorGridFSBucket.delete()
MotorGridFSBucket.download_to_stream()
MotorGridFSBucket.download_to_stream_by_name()
MotorGridFSBucket.find()
MotorGridFSBucket.open_download_stream()
MotorGridFSBucket.open_download_stream_by_name()
MotorGridFSBucket.open_upload_stream()
MotorGridFSBucket.open_upload_stream_with_id()
MotorGridFSBucket.rename()
MotorGridFSBucket.upload_from_stream()
MotorGridFSBucket.upload_from_stream_with_id()
MotorGridIn
MotorGridIn.abort()
MotorGridIn.close()
MotorGridIn.set()
MotorGridIn.write()
MotorGridIn.writelines()
MotorGridIn.chunk_size
MotorGridIn.closed
MotorGridIn.content_type
MotorGridIn.filename
MotorGridIn.length
MotorGridIn.name
MotorGridIn.read
MotorGridIn.readable
MotorGridIn.seekable
MotorGridIn.upload_date
MotorGridIn.writeable
MotorGridOut
MotorGridOut.open()
MotorGridOut.read()
MotorGridOut.readchunk()
MotorGridOut.readline()
MotorGridOut.stream_to_handler()
MotorGridOut.aliases
MotorGridOut.chunk_size
MotorGridOut.close
MotorGridOut.content_type
MotorGridOut.filename
MotorGridOut.length
MotorGridOut.metadata
MotorGridOut.name
MotorGridOut.readable
MotorGridOut.seek
MotorGridOut.seekable
MotorGridOut.tell
MotorGridOut.upload_date
MotorGridOut.write
MotorGridOutCursor
MotorGridOutCursor.allow_disk_use()
MotorGridOutCursor.clone()
MotorGridOutCursor.close()
MotorGridOutCursor.collation()
MotorGridOutCursor.comment()
MotorGridOutCursor.distinct()
MotorGridOutCursor.each()
MotorGridOutCursor.explain()
MotorGridOutCursor.hint()
MotorGridOutCursor.limit()
MotorGridOutCursor.max()
MotorGridOutCursor.max_await_time_ms()
MotorGridOutCursor.max_scan()
MotorGridOutCursor.max_time_ms()
MotorGridOutCursor.min()
MotorGridOutCursor.next()
MotorGridOutCursor.next_object()
MotorGridOutCursor.rewind()
MotorGridOutCursor.skip()
MotorGridOutCursor.sort()
MotorGridOutCursor.to_list()
MotorGridOutCursor.where()
MotorGridOutCursor.address
MotorGridOutCursor.alive
MotorGridOutCursor.cursor_id
MotorGridOutCursor.fetch_next
MotorGridOutCursor.session
motor.web
- Integrate Motor with the Tornado web framework
- Motor asyncio API
AsyncIOMotorClient
– Connection to MongoDBAsyncIOMotorClient
AsyncIOMotorClient.drop_database()
AsyncIOMotorClient.get_database()
AsyncIOMotorClient.get_default_database()
AsyncIOMotorClient.list_database_names()
AsyncIOMotorClient.list_databases()
AsyncIOMotorClient.server_info()
AsyncIOMotorClient.start_session()
AsyncIOMotorClient.watch()
AsyncIOMotorClient.HOST
AsyncIOMotorClient.PORT
AsyncIOMotorClient.address
AsyncIOMotorClient.arbiters
AsyncIOMotorClient.close
AsyncIOMotorClient.codec_options
AsyncIOMotorClient.is_mongos
AsyncIOMotorClient.is_primary
AsyncIOMotorClient.nodes
AsyncIOMotorClient.options
AsyncIOMotorClient.primary
AsyncIOMotorClient.read_concern
AsyncIOMotorClient.read_preference
AsyncIOMotorClient.secondaries
AsyncIOMotorClient.topology_description
AsyncIOMotorClient.write_concern
AsyncIOMotorClientSession
– Sequence of operationsAsyncIOMotorClientSession
AsyncIOMotorClientSession.abort_transaction()
AsyncIOMotorClientSession.commit_transaction()
AsyncIOMotorClientSession.end_session()
AsyncIOMotorClientSession.start_transaction()
AsyncIOMotorClientSession.with_transaction()
AsyncIOMotorClientSession.advance_cluster_time
AsyncIOMotorClientSession.advance_operation_time
AsyncIOMotorClientSession.client
AsyncIOMotorClientSession.cluster_time
AsyncIOMotorClientSession.has_ended
AsyncIOMotorClientSession.in_transaction
AsyncIOMotorClientSession.operation_time
AsyncIOMotorClientSession.options
AsyncIOMotorClientSession.session_id
AsyncIOMotorDatabase
AsyncIOMotorDatabase
AsyncIOMotorDatabase.aggregate()
AsyncIOMotorDatabase.command()
AsyncIOMotorDatabase.create_collection()
AsyncIOMotorDatabase.cursor_command()
AsyncIOMotorDatabase.dereference()
AsyncIOMotorDatabase.drop_collection()
AsyncIOMotorDatabase.get_collection()
AsyncIOMotorDatabase.list_collection_names()
AsyncIOMotorDatabase.list_collections()
AsyncIOMotorDatabase.validate_collection()
AsyncIOMotorDatabase.watch()
AsyncIOMotorDatabase.with_options()
AsyncIOMotorDatabase.client
AsyncIOMotorDatabase.codec_options
AsyncIOMotorDatabase.name
AsyncIOMotorDatabase.read_concern
AsyncIOMotorDatabase.read_preference
AsyncIOMotorDatabase.write_concern
AsyncIOMotorCollection
AsyncIOMotorCollection
AsyncIOMotorCollection.database
AsyncIOMotorCollection.aggregate()
AsyncIOMotorCollection.aggregate_raw_batches()
AsyncIOMotorCollection.bulk_write()
AsyncIOMotorCollection.count_documents()
AsyncIOMotorCollection.create_index()
AsyncIOMotorCollection.create_indexes()
AsyncIOMotorCollection.create_search_index()
AsyncIOMotorCollection.create_search_indexes()
AsyncIOMotorCollection.delete_many()
AsyncIOMotorCollection.delete_one()
AsyncIOMotorCollection.distinct()
AsyncIOMotorCollection.drop()
AsyncIOMotorCollection.drop_index()
AsyncIOMotorCollection.drop_indexes()
AsyncIOMotorCollection.drop_search_index()
AsyncIOMotorCollection.estimated_document_count()
AsyncIOMotorCollection.find()
AsyncIOMotorCollection.find_one()
AsyncIOMotorCollection.find_one_and_delete()
AsyncIOMotorCollection.find_one_and_replace()
AsyncIOMotorCollection.find_one_and_update()
AsyncIOMotorCollection.find_raw_batches()
AsyncIOMotorCollection.index_information()
AsyncIOMotorCollection.insert_many()
AsyncIOMotorCollection.insert_one()
AsyncIOMotorCollection.list_indexes()
AsyncIOMotorCollection.list_search_indexes()
AsyncIOMotorCollection.options()
AsyncIOMotorCollection.rename()
AsyncIOMotorCollection.replace_one()
AsyncIOMotorCollection.update_many()
AsyncIOMotorCollection.update_one()
AsyncIOMotorCollection.update_search_index()
AsyncIOMotorCollection.watch()
AsyncIOMotorCollection.with_options()
AsyncIOMotorCollection.codec_options
AsyncIOMotorCollection.full_name
AsyncIOMotorCollection.name
AsyncIOMotorCollection.read_concern
AsyncIOMotorCollection.read_preference
AsyncIOMotorCollection.write_concern
AsyncIOMotorChangeStream
AsyncIOMotorClientEncryption
AsyncIOMotorClientEncryption
AsyncIOMotorClientEncryption.add_key_alt_name()
AsyncIOMotorClientEncryption.close()
AsyncIOMotorClientEncryption.create_data_key()
AsyncIOMotorClientEncryption.create_encrypted_collection()
AsyncIOMotorClientEncryption.decrypt()
AsyncIOMotorClientEncryption.delete_key()
AsyncIOMotorClientEncryption.encrypt()
AsyncIOMotorClientEncryption.encrypt_expression()
AsyncIOMotorClientEncryption.get_key()
AsyncIOMotorClientEncryption.get_key_by_alt_name()
AsyncIOMotorClientEncryption.remove_key_alt_name()
AsyncIOMotorClientEncryption.rewrap_many_data_key()
AsyncIOMotorCursor
AsyncIOMotorCursor
AsyncIOMotorCursor.add_option()
AsyncIOMotorCursor.allow_disk_use()
AsyncIOMotorCursor.clone()
AsyncIOMotorCursor.close()
AsyncIOMotorCursor.collation()
AsyncIOMotorCursor.comment()
AsyncIOMotorCursor.distinct()
AsyncIOMotorCursor.each()
AsyncIOMotorCursor.explain()
AsyncIOMotorCursor.hint()
AsyncIOMotorCursor.limit()
AsyncIOMotorCursor.max()
AsyncIOMotorCursor.max_await_time_ms()
AsyncIOMotorCursor.max_scan()
AsyncIOMotorCursor.max_time_ms()
AsyncIOMotorCursor.min()
AsyncIOMotorCursor.next()
AsyncIOMotorCursor.next_object()
AsyncIOMotorCursor.remove_option()
AsyncIOMotorCursor.rewind()
AsyncIOMotorCursor.skip()
AsyncIOMotorCursor.sort()
AsyncIOMotorCursor.to_list()
AsyncIOMotorCursor.where()
AsyncIOMotorCursor.address
AsyncIOMotorCursor.alive
AsyncIOMotorCursor.cursor_id
AsyncIOMotorCursor.fetch_next
AsyncIOMotorCursor.session
AsyncIOMotorCommandCursor
AsyncIOMotorCommandCursor
AsyncIOMotorCommandCursor.close()
AsyncIOMotorCommandCursor.each()
AsyncIOMotorCommandCursor.next()
AsyncIOMotorCommandCursor.next_object()
AsyncIOMotorCommandCursor.to_list()
AsyncIOMotorCommandCursor.try_next()
AsyncIOMotorCommandCursor.address
AsyncIOMotorCommandCursor.alive
AsyncIOMotorCommandCursor.cursor_id
AsyncIOMotorCommandCursor.fetch_next
AsyncIOMotorCommandCursor.session
- asyncio GridFS Classes
AsyncIOMotorGridFSBucket
AsyncIOMotorGridFSBucket.delete()
AsyncIOMotorGridFSBucket.download_to_stream()
AsyncIOMotorGridFSBucket.download_to_stream_by_name()
AsyncIOMotorGridFSBucket.find()
AsyncIOMotorGridFSBucket.open_download_stream()
AsyncIOMotorGridFSBucket.open_download_stream_by_name()
AsyncIOMotorGridFSBucket.open_upload_stream()
AsyncIOMotorGridFSBucket.open_upload_stream_with_id()
AsyncIOMotorGridFSBucket.rename()
AsyncIOMotorGridFSBucket.upload_from_stream()
AsyncIOMotorGridFSBucket.upload_from_stream_with_id()
AsyncIOMotorGridIn
AsyncIOMotorGridIn.abort()
AsyncIOMotorGridIn.close()
AsyncIOMotorGridIn.set()
AsyncIOMotorGridIn.write()
AsyncIOMotorGridIn.writelines()
AsyncIOMotorGridIn.chunk_size
AsyncIOMotorGridIn.closed
AsyncIOMotorGridIn.content_type
AsyncIOMotorGridIn.filename
AsyncIOMotorGridIn.length
AsyncIOMotorGridIn.name
AsyncIOMotorGridIn.read
AsyncIOMotorGridIn.readable
AsyncIOMotorGridIn.seekable
AsyncIOMotorGridIn.upload_date
AsyncIOMotorGridIn.writeable
AsyncIOMotorGridOut
AsyncIOMotorGridOut.open()
AsyncIOMotorGridOut.read()
AsyncIOMotorGridOut.readchunk()
AsyncIOMotorGridOut.readline()
AsyncIOMotorGridOut.stream_to_handler()
AsyncIOMotorGridOut.aliases
AsyncIOMotorGridOut.chunk_size
AsyncIOMotorGridOut.close
AsyncIOMotorGridOut.content_type
AsyncIOMotorGridOut.filename
AsyncIOMotorGridOut.length
AsyncIOMotorGridOut.metadata
AsyncIOMotorGridOut.name
AsyncIOMotorGridOut.readable
AsyncIOMotorGridOut.seek
AsyncIOMotorGridOut.seekable
AsyncIOMotorGridOut.tell
AsyncIOMotorGridOut.upload_date
AsyncIOMotorGridOut.write
AsyncIOMotorGridOutCursor
AsyncIOMotorGridOutCursor.allow_disk_use()
AsyncIOMotorGridOutCursor.clone()
AsyncIOMotorGridOutCursor.close()
AsyncIOMotorGridOutCursor.collation()
AsyncIOMotorGridOutCursor.comment()
AsyncIOMotorGridOutCursor.distinct()
AsyncIOMotorGridOutCursor.each()
AsyncIOMotorGridOutCursor.explain()
AsyncIOMotorGridOutCursor.hint()
AsyncIOMotorGridOutCursor.limit()
AsyncIOMotorGridOutCursor.max()
AsyncIOMotorGridOutCursor.max_await_time_ms()
AsyncIOMotorGridOutCursor.max_scan()
AsyncIOMotorGridOutCursor.max_time_ms()
AsyncIOMotorGridOutCursor.min()
AsyncIOMotorGridOutCursor.next()
AsyncIOMotorGridOutCursor.next_object()
AsyncIOMotorGridOutCursor.rewind()
AsyncIOMotorGridOutCursor.skip()
AsyncIOMotorGridOutCursor.sort()
AsyncIOMotorGridOutCursor.to_list()
AsyncIOMotorGridOutCursor.where()
AsyncIOMotorGridOutCursor.address
AsyncIOMotorGridOutCursor.alive
AsyncIOMotorGridOutCursor.cursor_id
AsyncIOMotorGridOutCursor.fetch_next
AsyncIOMotorGridOutCursor.session
motor.aiohttp
- Integrate Motor with the aiohttp web framework
Logo by Musho Rodney Alan Greenblat