Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Calcul scientifique
avec Python
Voir le programme détaillé
Classe « MetaData »

Méthode sqlalchemy.MetaData.reflect

Signature de la méthode reflect

def reflect(self, bind: 'Union[Engine, Connection]', schema: 'Optional[str]' = None, views: 'bool' = False, only: 'Union[_typing_Sequence[str], Callable[[str, MetaData], bool], None]' = None, extend_existing: 'bool' = False, autoload_replace: 'bool' = True, resolve_fks: 'bool' = True, **dialect_kwargs: 'Any') -> 'None' 

Description

help(MetaData.reflect)

Load all available table definitions from the database.

Automatically creates ``Table`` entries in this ``MetaData`` for any
table available in the database but not yet present in the
``MetaData``.  May be called multiple times to pick up tables recently
added to the database, however no special action is taken if a table
in this ``MetaData`` no longer exists in the database.

:param bind:
  A :class:`.Connection` or :class:`.Engine` used to access the
  database.

:param schema:
  Optional, query and reflect tables from an alternate schema.
  If None, the schema associated with this :class:`_schema.MetaData`
  is used, if any.

:param views:
  If True, also reflect views (materialized and plain).

:param only:
  Optional.  Load only a sub-set of available named tables.  May be
  specified as a sequence of names or a callable.

  If a sequence of names is provided, only those tables will be
  reflected.  An error is raised if a table is requested but not
  available.  Named tables already present in this ``MetaData`` are
  ignored.

  If a callable is provided, it will be used as a boolean predicate to
  filter the list of potential table names.  The callable is called
  with a table name and this ``MetaData`` instance as positional
  arguments and should return a true value for any table to reflect.

:param extend_existing: Passed along to each :class:`_schema.Table` as
  :paramref:`_schema.Table.extend_existing`.

:param autoload_replace: Passed along to each :class:`_schema.Table`
  as
  :paramref:`_schema.Table.autoload_replace`.

:param resolve_fks: if True, reflect :class:`_schema.Table`
 objects linked
 to :class:`_schema.ForeignKey` objects located in each
 :class:`_schema.Table`.
 For :meth:`_schema.MetaData.reflect`,
 this has the effect of reflecting
 related tables that might otherwise not be in the list of tables
 being reflected, for example if the referenced table is in a
 different schema or is omitted via the
 :paramref:`.MetaData.reflect.only` parameter.  When False,
 :class:`_schema.ForeignKey` objects are not followed to the
 :class:`_schema.Table`
 in which they link, however if the related table is also part of the
 list of tables that would be reflected in any case, the
 :class:`_schema.ForeignKey` object will still resolve to its related
 :class:`_schema.Table` after the :meth:`_schema.MetaData.reflect`
 operation is
 complete.   Defaults to True.

 .. versionadded:: 1.3.0

 .. seealso::

    :paramref:`_schema.Table.resolve_fks`

:param \**dialect_kwargs: Additional keyword arguments not mentioned
 above are dialect specific, and passed in the form
 ``<dialectname>_<argname>``.  See the documentation regarding an
 individual dialect at :ref:`dialect_toplevel` for detail on
 documented arguments.

.. seealso::

    :ref:`metadata_reflection_toplevel`

    :meth:`_events.DDLEvents.column_reflect` - Event used to customize
    the reflected columns. Usually used to generalize the types using
    :meth:`_types.TypeEngine.as_generic`

    :ref:`metadata_reflection_dbagnostic_types` - describes how to
    reflect tables using general types.



Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les fondamentaux
Voir le programme détaillé