SQLAlchemy 2.0.0 officially released, Python ORM framework

SQLAlchemy 2.0.0 is the first production-ready version of the SQLAlchemy 2.0 series and is now officially GA.

SQLAlchemy is a Python SQL toolkit and database object mapping (ORM) framework. It contains a complete set of enterprise-level persistence patterns designed for efficient and high-performance database access.

2.0 is designed to accommodate the practical use of modern Python , and the development team has spent more than three years upgrading the SQLAlchemy use-case model and architecture. They say that since the first release of SQLAlchemy in 2006, three major Python paradigms have emerged: Python 3, pep-484 type support, and asyncio. The 2.0 update of SQLAlchemy is precisely to adapt to the constant changes in the Python community. And compared to 16 years ago, the Python community is larger, with more new developers, who have higher standards for rigor, ease of use, and documentation.

According to reports, the history of the SQLAlchemy 2.0 series began four years ago on August 8, 2018, with some short thoughts on how to unify the core concepts of SQLAlchemy and ORM queries. The first plan for the real "SQLAlchemy 2.0" concept was formed in November of that year, focusing on greatly simplifying the Core execution and transaction APIs , and seeking to unify queries across Core and ORM.

The changes to the underlying concepts are so pronounced that SQLAlchemy 2.0 is broken into two major phases. The first stage is the  SQLAlchemy 1.4  series, which provides a new unified Core/ORM SQL query system, while building on a new general statement cache architecture. This phase provides a complete implementation of SQLAlchemy 2.0's SQL build methods (minimum pep-484 type support), while fully maintaining the legacy query API. Along with this release, a comprehensive  migration path  inspired by lessons learned during the Python 2->3 migration process describes how to port applications so that they can continue to run in SQLAlchemy 1.4 while being fully forward compatible with SQLAlchemy 2.0.

The second phase is the  SQLAlchemy 2.0  series, which removes most of the deprecated elements, relegates the remaining elements (mainly Query) to a long-term "legacy" state, and only fully migrates to Python 3, while adding many new features in the new architecture. New features built on top of it, taking full advantage of Python 3 features (including data classes, enums, inline comments) and the new unified query architecture.

A key advantage of this approach is that the most significant and by far riskiest architectural change, the one that rewrites Core/ORM queries on top of the new caching layer, has been in production with SQLAlchemy 1.4 for almost two years. So while SQLAlchemy 2.0 will certainly have many new problems once it is used by all developers, they should not be "new cracks in the foundational approach", since the architectural foundation is already widely used.

Officials expect the vast majority of issues to be related to the new type system, and problems adjusting existing applications to use the new API.

SQLAlchemy 2.0 is a very large version update, and it has two migration guides:

  • Major Migration Guide  - Describes how to make your application API Compatible so that it runs equally in SQLAlchemy 1.4 or 2.0
  • New  in SQLAlchemy 2.0 - Provides all the new features and APIs that are available to applications running on SQLAlchemy 2.0.

For detailed update instructions, see the release announcement .

おすすめ

転載: www.oschina.net/news/225996/sqlalchemy-2-0-0-released