diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-10-12 13:16:14 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-10-12 13:57:43 -0400 |
commit | c76e3776f52d0d69c8c4932ba53626d7190cf5f4 (patch) | |
tree | 224282cf4390f136228a932a40dbb504824b273b /lib/sqlalchemy/sql/schema.py | |
parent | 286fe9b0b165e46099066cc16552b93a0b853a7e (diff) | |
download | sqlalchemy-c76e3776f52d0d69c8c4932ba53626d7190cf5f4.tar.gz |
Deprecate bound metadata
The :paramref:`_schema.MetaData.bind` argument as well as the overall
concept of "bound metadata" is deprecated in SQLAlchemy 1.4 and will be
removed in SQLAlchemy 2.0. The parameter as well as related functions now
emit a :class:`_exc.RemovedIn20Warning` when :ref:`deprecation_20_mode` is
in use.
Added new parameter :paramref:`_automap.AutomapBase.prepare.autoload_with`
which supersedes :paramref:`_automap.AutomapBase.prepare.reflect`
and :paramref:`_automap.AutomapBase.prepare.engine`.
Fixes: #4634
Fixes: #5142
Change-Id: Iaabf9b481931e2fb68b97b5954c32e65772a298e
Diffstat (limited to 'lib/sqlalchemy/sql/schema.py')
-rw-r--r-- | lib/sqlalchemy/sql/schema.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 50d7d1f5b..770c02ef5 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -843,6 +843,9 @@ class Table(DialectKWArgs, SchemaItem, TableClause): :class:`_schema.Table`, using the given :class:`.Connectable` for connectivity. + .. note:: the "bind" argument will be required in + SQLAlchemy 2.0. + .. seealso:: :meth:`_schema.MetaData.create_all`. @@ -858,6 +861,9 @@ class Table(DialectKWArgs, SchemaItem, TableClause): :class:`_schema.Table`, using the given :class:`.Connectable` for connectivity. + .. note:: the "bind" argument will be required in + SQLAlchemy 2.0. + .. seealso:: :meth:`_schema.MetaData.drop_all`. @@ -2672,14 +2678,24 @@ class Sequence(IdentityOptions, roles.StatementRole, DefaultGenerator): return None def create(self, bind=None, checkfirst=True): - """Creates this sequence in the database.""" + """Creates this sequence in the database. + + .. note:: the "bind" argument will be required in + SQLAlchemy 2.0. + + """ if bind is None: bind = _bind_or_error(self) bind._run_ddl_visitor(ddl.SchemaGenerator, self, checkfirst=checkfirst) def drop(self, bind=None, checkfirst=True): - """Drops this sequence from the database.""" + """Drops this sequence from the database. + + .. note:: the "bind" argument will be required in + SQLAlchemy 2.0. + + """ if bind is None: bind = _bind_or_error(self) @@ -3904,6 +3920,13 @@ class MetaData(SchemaItem): __visit_name__ = "metadata" + @util.deprecated_params( + bind=( + "2.0", + "The :paramref:`_schema.MetaData.bind` argument is deprecated and " + "will be removed in SQLAlchemy 2.0.", + ), + ) def __init__( self, bind=None, @@ -4431,6 +4454,9 @@ class MetaData(SchemaItem): database; if None, uses the existing bind on this ``MetaData``, if any. + .. note:: the "bind" argument will be required in + SQLAlchemy 2.0. + :param tables: Optional list of ``Table`` objects, which is a subset of the total tables in the ``MetaData`` (others are ignored). @@ -4457,6 +4483,9 @@ class MetaData(SchemaItem): database; if None, uses the existing bind on this ``MetaData``, if any. + .. note:: the "bind" argument will be required in + SQLAlchemy 2.0. + :param tables: Optional list of ``Table`` objects, which is a subset of the total tables in the ``MetaData`` (others are ignored). |