summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/create.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-11-01 15:44:44 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-11-07 14:30:35 -0500
commitd050193daaa8d91371c759296f3304b8641c1976 (patch)
treef3f880ccd528d1dc6c1dafa1a19b71c7c953fdce /lib/sqlalchemy/engine/create.py
parent248d232459e38561999c4172acaaddd651c1a933 (diff)
downloadsqlalchemy-d050193daaa8d91371c759296f3304b8641c1976.tar.gz
fully implement future engine and remove legacy
The major action here is to lift and move future.Connection and future.Engine fully into sqlalchemy.engine.base. This removes lots of engine concepts, including: * autocommit * Connection running without a transaction, autobegin is now present in all cases * most "autorollback" is obsolete * Core-level subtransactions (i.e. MarkerTransaction) * "branched" connections, copies of connections * execution_options() returns self, not a new connection * old argument formats, distill_params(), simplifies calling scheme between engine methods * before/after_execute() events (oriented towards compiled constructs) don't emit for exec_driver_sql(). before/after_cursor_execute() is still included for this * old helper methods superseded by context managers, connection.transaction(), engine.transaction() engine.run_callable() * ancient engine-level reflection methods has_table(), table_names() * sqlalchemy.testing.engines.proxying_engine References: #7257 Change-Id: Ib20ed816642d873b84221378a9ec34480e01e82c
Diffstat (limited to 'lib/sqlalchemy/engine/create.py')
-rw-r--r--lib/sqlalchemy/engine/create.py33
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/sqlalchemy/engine/create.py b/lib/sqlalchemy/engine/create.py
index b9e111647..6e5a07098 100644
--- a/lib/sqlalchemy/engine/create.py
+++ b/lib/sqlalchemy/engine/create.py
@@ -230,11 +230,21 @@ def create_engine(url, **kwargs):
be applied to all connections. See
:meth:`~sqlalchemy.engine.Connection.execution_options`
- :param future: Use the 2.0 style :class:`_future.Engine` and
- :class:`_future.Connection` API.
+ :param future: Use the 2.0 style :class:`_engine.Engine` and
+ :class:`_engine.Connection` API.
+
+ As of SQLAlchemy 2.0, this parameter is present for backwards
+ compatibility only and must remain at its default value of ``True``.
+
+ The :paramref:`_sa.create_engine.future` parameter will be
+ deprecated in a subsequent 2.x release and eventually removed.
.. versionadded:: 1.4
+ .. versionchanged:: 2.0 All :class:`_engine.Engine` objects are
+ "future" style engines and there is no longer a ``future=False``
+ mode of operation.
+
.. seealso::
:ref:`migration_20_toplevel`
@@ -613,14 +623,13 @@ def create_engine(url, **kwargs):
pool._dialect = dialect
# create engine.
- if pop_kwarg("future", False):
- from sqlalchemy import future
-
- default_engine_class = future.Engine
- else:
- default_engine_class = base.Engine
+ if not pop_kwarg("future", True):
+ raise exc.ArgumentError(
+ "The 'future' parameter passed to "
+ "create_engine() may only be set to True."
+ )
- engineclass = kwargs.pop("_future_engine_class", default_engine_class)
+ engineclass = base.Engine
engine_args = {}
for k in util.get_cls_kwargs(engineclass):
@@ -630,7 +639,6 @@ def create_engine(url, **kwargs):
# internal flags used by the test suite for instrumenting / proxying
# engines with mocks etc.
_initialize = kwargs.pop("_initialize", True)
- _wrap_do_on_connect = kwargs.pop("_wrap_do_on_connect", None)
# all kwargs should be consumed
if kwargs:
@@ -652,8 +660,6 @@ def create_engine(url, **kwargs):
if _initialize:
do_on_connect = dialect.on_connect_url(u)
if do_on_connect:
- if _wrap_do_on_connect:
- do_on_connect = _wrap_do_on_connect(do_on_connect)
def on_connect(dbapi_connection, connection_record):
do_on_connect(dbapi_connection)
@@ -668,6 +674,9 @@ def create_engine(url, **kwargs):
# reconnecting will be a reentrant condition, so if the
# connection goes away, Connection is then closed
_allow_revalidate=False,
+ # dont trigger the autobegin sequence
+ # within the up front dialect checks
+ _allow_autobegin=False,
)
c._execution_options = util.EMPTY_DICT