SQLAlchemy 2.0 Future (Core)

This package includes a relatively small number of transitional elements to allow “2.0 mode” to take place within SQLAlchemy 1.4. The primary objects provided here are Engine and Connection, which are both subclasses of the existing Engine and Connection objects with essentially a smaller set of methods and the removal of “autocommit”.

Within the 1.4 series, the “2.0” style of engines and connections is enabled by passing the create_engine.future flag to create_engine():

from sqlalchemy import create_engine

engine = create_engine("postgresql://user:pass@host/dbname", future=True)

Similarly, with the ORM, to enable “future” behavior in the ORM Session, pass the Session.future parameter either to the Session constructor directly, or via the sessionmaker class:

from sqlalchemy.orm import sessionmaker

Session = sessionmaker(engine, future=True)

See also

Migrating to SQLAlchemy 2.0 - Introduction to the 2.0 series of SQLAlchemy

Back to Top