Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

The Major Release of Motor 2.0

DZone's Guide to

The Major Release of Motor 2.0

To support multi-document transactions, I had to make breaking changes to Motor’s session API and release a major version bump, Motor 2.0.

· Database Zone ·
Free Resource

Download "Why Your MySQL Needs Redis" and discover how to extend your current MySQL or relational database to a Redis database.

To support multi-document transactions, I had to make breaking changes to Motor’s session API and release a major version bump, Motor 2.0. Since this is a major release, I also deleted many helper methods and APIs that had been deprecated over time since Motor 1.0, most notably the old CRUD methods insert, update, remove, and save, and the original callback-based API. Read the Motor 2.0 Migration Guide carefully to upgrade your existing Motor application. Motor 2.0 also includes a Python 3.7 compatibility fix in the MotorChangeStream class returned by MotorCollection.watch.

Motor 2.0’s changes have a big impact for some applications, so I created a bridge release that raises DeprecationWarning for all the APIs that are deleted in Motor 2.0, especially the callback API, which hasn’t been deprecated before. Those DeprecationWarnings plus the Python 3.7 compatibility fix constitute Motor 1.3.0.

For applications that only need Python 3.7 compatibility, I’ve created Motor 1.2.4, which includes the Python 3.7 fix and no other changes.

Detailed release notes follow.

Motor 2.0

Motor 2.0 drops support for MongoDB 2.6 and adds support for MongoDB 4.0 features including multi-document transactions and change stream notifications on entire databases or entire MongoDB servers. This version of Motor requires PyMongo 3.7 or later.

There is added support for aiohttp 3.0 and later, and older aiohttp versions were dropped. The aiohttp integration now requires Python 3.5+.

This is a major release that removes previously deprecated APIs.

The MotorDatabase.add_user and MotorDatabase.remove_user methods are deleted. Manage user accounts with four database commands: createUser, usersInfo, updateUser, and dropUser. You can run any database command with the MotorDatabase.command() method.

The deprecated GridFS classes MotorGridFS and AsyncIOMotorGridFS are deleted in favor of MotorGridFSBucket and AsyncIOMotorGridFSBucket, which conform to driver specs for GridFS.

Additional changes:

Motor 1.3.0

Deprecate Motor’s old callback-based async API in preparation for removing it in Motor 2.0. Raise DeprecationWarning whenever a callback is passed.

Motor 1.2.4

Fix a Python 3.7 compatibility bug in the MotorChangeStream class returned by MotorCollection.watch(). It is now possible to use change streams in async for loops in Python 3.7.

If you find issues, file a bug, and I’ll respond promptly. If it works for you, don’t be silent! Tweet me and tell me!

Read "Developing Apps Using Active-Active Redis Enterprise" and discover the advantages over other active-actve databases.

Topics:
database ,motor 2.0 ,motor ,aiohttp

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}