1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
.. _core_future_toplevel:
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 :class:`_future.Engine` and :class:`_future.Connection`,
which are both subclasses of the existing :class:`_engine.Engine` and
:class:`_engine.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 :paramref:`_sa.create_engine.future` flag to
:func:`_sa.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 :class:`.Session`,
pass the :paramref:`_orm.Session.future` parameter either to the
:class:`.Session` constructor directly, or via the :class:`_orm.sessionmaker`
class::
from sqlalchemy.orm import sessionmaker
Session = sessionmaker(engine, future=True)
.. seealso::
:ref:`migration_20_toplevel` - Introduction to the 2.0 series of SQLAlchemy
.. module:: sqlalchemy.future
.. autoclass:: sqlalchemy.future.Connection
:members:
.. autofunction:: sqlalchemy.future.create_engine
.. autoclass:: sqlalchemy.future.Engine
:members:
.. autofunction:: sqlalchemy.future.select
|