diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2021-11-07 21:19:45 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-11-07 21:19:45 +0000 |
commit | 201c00bc0837af831f115e8313ad3ccb0be97e7a (patch) | |
tree | beb7558e95d073b63fa4bb76d830ccaa2de9711a /lib/sqlalchemy/engine/create.py | |
parent | 5b1c9053b0903b2d5a06f82b47fe16a870696ddc (diff) | |
parent | d050193daaa8d91371c759296f3304b8641c1976 (diff) | |
download | sqlalchemy-201c00bc0837af831f115e8313ad3ccb0be97e7a.tar.gz |
Merge "fully implement future engine and remove legacy" into main
Diffstat (limited to 'lib/sqlalchemy/engine/create.py')
-rw-r--r-- | lib/sqlalchemy/engine/create.py | 33 |
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 |