changelog_render_changeset = "https://www.sqlalchemy.org/trac/changeset/%s"
-exclude_patterns = ["build", "**/unreleased*/*", "**/*_include.rst"]
+exclude_patterns = ["build", "**/unreleased*/*", "**/*_include.rst", ".venv"]
autodoc_class_signature = "separated"
>>> from sqlalchemy import column, select
>>> from sqlalchemy import create_engine
- >>> engine = create_engine("sqlite+pysqlite:///:memory:", echo=True, future=True)
+ >>> engine = create_engine("sqlite+pysqlite:///:memory:", echo=True)
>>> from sqlalchemy import MetaData, Table, Column, Integer, String, Numeric
>>> metadata_obj = MetaData()
>>> user_table = Table(
.. seealso::
- :ref:`subqueryload_ordering`
+ :ref:`subquery_eager_loading`
provides accessors to allow modifications to statements, parameters, and
options::
- Session = sessionmaker(engine, future=True)
+ Session = sessionmaker(engine)
@event.listens_for(Session, "do_orm_execute")
from sqlalchemy.orm import with_loader_criteria
- Session = sessionmaker(engine, future=True)
+ Session = sessionmaker(engine)
@event.listens_for(Session, "do_orm_execute")
Session-level vs. Engine level transaction control
--------------------------------------------------
-As of SQLAlchemy 1.4, the :class:`_orm.sessionmaker` and Core
-:class:`_engine.Engine` objects both support :term:`2.0 style` operation,
-by making use of the :paramref:`_orm.Session.future` flag as well as the
-:paramref:`_engine.create_engine.future` flag so that these two objects
-assume 2.0-style semantics.
-
-When using future mode, there should be equivalent semantics between
-the two packages, at the level of the :class:`_orm.sessionmaker` vs.
+The :class:`_engine.Connection` in Core and
+:class:`_session.Session` in ORM feature equivalent transactional
+semantics, both at the level of the :class:`_orm.sessionmaker` vs.
the :class:`_engine.Engine`, as well as the :class:`_orm.Session` vs.
the :class:`_engine.Connection`. The following sections detail
these scenarios based on the following scheme:
.. sourcecode:: text
- ORM (using future Session) Core (using future engine)
+ ORM Core
----------------------------------------- -----------------------------------
sessionmaker Engine
Session Connection
Engine::
- engine = create_engine("postgresql+psycopg2://user:pass@host/dbname", future=True)
+ engine = create_engine("postgresql+psycopg2://user:pass@host/dbname")
with engine.begin() as conn:
conn.execute(
Session::
- Session = sessionmaker(engine, future=True)
+ Session = sessionmaker(engine)
with Session.begin() as session:
session.add_all(
Engine::
- engine = create_engine("postgresql+psycopg2://user:pass@host/dbname", future=True)
+ engine = create_engine("postgresql+psycopg2://user:pass@host/dbname")
with engine.begin() as conn:
savepoint = conn.begin_nested()
Session::
- Session = sessionmaker(engine, future=True)
+ Session = sessionmaker(engine)
with Session.begin() as session:
savepoint = session.begin_nested()
git+https://github.com/sqlalchemyorg/zzzeeksphinx.git#egg=zzzeeksphinx
sphinx-copybutton
sphinx-autobuild
+typing-extensions
.. seealso::
- :term:`executemany` - in the :doc:`Glossary <glossary>`, describes the
+ :term:`executemany` - in the :doc:`Glossary </glossary>`, describes the
DBAPI-level
`cursor.executemany() <https://peps.python.org/pep-0249/#executemany>`_
method that's used for most "executemany" executions.
For this tutorial we will use an in-memory-only SQLite database. This is an
easy way to test things without needing to have an actual pre-existing database
-set up. The :class:`_engine.Engine` is created by using :func:`_sa.create_engine`, specifying
-the :paramref:`_sa.create_engine.future` flag set to ``True`` so that we make full use
-of :term:`2.0 style` usage:
+set up. The :class:`_engine.Engine` is created by using the
+:func:`_sa.create_engine` function:
.. sourcecode:: pycon+sql
>>> from sqlalchemy import create_engine
- >>> engine = create_engine("sqlite+pysqlite:///:memory:", echo=True, future=True)
+ >>> engine = create_engine("sqlite+pysqlite:///:memory:", echo=True)
The main argument to :class:`_sa.create_engine`
is a string URL, above passed as the string ``"sqlite+pysqlite:///:memory:"``.
engine = create_engine("sqlite://", echo=True)
Base.metadata.create_all(engine)
- Session = sessionmaker(bind=engine, future=True)
+ Session = sessionmaker(bind=engine)
sess = Session()
engine = create_engine("sqlite://", echo=True)
Base.metadata.create_all(engine)
- Session = sessionmaker(bind=engine, future=True)
+ Session = sessionmaker(bind=engine)
sess = Session()
# to databases within a ShardedSession and returns it.
Session = sessionmaker(
class_=ShardedSession,
- future=True,
shards={
"north_america": db1,
"asia": db2,
# to databases within a ShardedSession and returns it.
Session = sessionmaker(
class_=ShardedSession,
- future=True,
shards={
"north_america": db1,
"asia": db2,
# to databases within a ShardedSession and returns it.
Session = sessionmaker(
class_=ShardedSession,
- future=True,
shards={
"north_america": db1,
"asia": db2,