Overview

SQLAlchemy 1.4, released on March 16, 2021, is a transition release toward the 2.0 style. The future mode lets you progressively adopt the new API.

Main Features

Future mode (2.0 style)

The future=True parameter on the engine and session enables the 2.0 style: queries use select() instead of session.query(), providing a more explicit and consistent API.

python
from sqlalchemy import create_engine, select
from sqlalchemy.orm import Session
from models import User

# Future mode for 2.0 style
engine = create_engine('sqlite:///app.db', future=True)

with Session(engine) as session:
    # 2.0 style: explicit select()
    stmt = select(User).where(User.age > 18)
    results = session.execute(stmt).scalars().all()
    for u in results:
        print(f'{u.name} ({u.age} years old)')

2.0-style queries

The 2.0-style queries unify Core and ORM around select(), insert(), update(), and delete(). Results are returned via session.execute() instead of session.query().

python
from sqlalchemy import select, func

# Aggregation with 2.0 style
stmt = (
    select(User.city, func.count())
    .group_by(User.city)
    .having(func.count() > 5)
)
for city, count in session.execute(stmt):
    print(f'{city}: {count} users')

Sources