class documentation

Performs database schema inspection. The Inspector acts as a proxy to the reflection methods of the :class:`~sqlalchemy.engine.interfaces.Dialect`, providing a consistent interface as well as caching support for previously fetched metadata. A :class:`_reflection.Inspector` object is usually created via the :func:`_sa.inspect` function, which may be passed an :class:`_engine.Engine` or a :class:`_engine.Connection`:: from sqlalchemy import inspect, create_engine engine = create_engine('...') insp = inspect(engine) Where above, the :class:`~sqlalchemy.engine.interfaces.Dialect` associated with the engine may opt to return an :class:`_reflection.Inspector` subclass that provides additional methods specific to the dialect's target database.

Class Method from_engine Construct a new dialect-specific Inspector object from the given engine or connection.
Method __init__ Initialize a new :class:`_reflection.Inspector`.
Method clear_cache reset the cache for this :class:`.Inspector`.
Method get_check_constraints Return information about check constraints in ``table_name``.
Method get_columns Return information about columns in ``table_name``.
Method get_foreign_keys Return information about foreign_keys in ``table_name``.
Method get_indexes Return information about indexes in ``table_name``.
Method get_materialized_view_names Return all materialized view names in `schema`.
Method get_multi_check_constraints Return information about check constraints in all tables in the given schema.
Method get_multi_columns Return information about columns in all objects in the given schema.
Method get_multi_foreign_keys Return information about foreign_keys in all tables in the given schema.
Method get_multi_indexes Return information about indexes in in all objects in the given schema.
Method get_multi_pk_constraint Return information about primary key constraints in all tables in the given schema.
Method get_multi_table_comment Return information about the table comment in all objects in the given schema.
Method get_multi_table_options Return a dictionary of options specified when the tables in the given schema were created.
Method get_multi_unique_constraints Return information about unique constraints in all tables in the given schema.
Method get_pk_constraint Return information about primary key constraint in ``table_name``.
Method get_schema_names Return all schema names.
Method get_sequence_names Return all sequence names in `schema`.
Method get_sorted_table_and_fkc_names Return dependency-sorted table and foreign key constraint names in referred to within a particular schema.
Method get_table_comment Return information about the table comment for ``table_name``.
Method get_table_names Return all table names within a particular schema.
Method get_table_options Return a dictionary of options specified when the table of the given name was created.
Method get_temp_table_names Return a list of temporary table names for the current bind.
Method get_temp_view_names Return a list of temporary view names for the current bind.
Method get_unique_constraints Return information about unique constraints in ``table_name``.
Method get_view_definition Return definition for the plain or materialized view called ``view_name``.
Method get_view_names Return all non-materialized view names in `schema`.
Method has_index Check the existence of a particular index name in the database.
Method has_schema Return True if the backend has a schema with the given name.
Method has_sequence Return True if the backend has a sequence with the given name.
Method has_table Return True if the backend has a table, view, or temporary table of the given name.
Method reflect_table Given a :class:`_schema.Table` object, load its internal constructs based on introspection.
Method sort_tables_on_foreign_key_dependency Return dependency-sorted table and foreign key constraint names referred to within multiple schemas.
Instance Variable bind Undocumented
Instance Variable dialect Undocumented
Instance Variable engine Undocumented
Instance Variable info_cache Undocumented
Property default_schema_name Return the default schema name presented by the dialect for the current engine's database user.
Class Method _construct Undocumented
Method _connection_insp Undocumented
Method _engine_insp Undocumented
Method _get_reflection_info Undocumented
Method _init_connection Undocumented
Method _init_engine Undocumented
Method _init_legacy Undocumented
Method _inspection_context Return an :class:`_reflection.Inspector` from this one that will run all operations on a single connection.
Method _instantiate_types Undocumented
Method _operation_context Return a context that optimizes for multiple operations on a single transaction.
Method _reflect_check_constraints Undocumented
Method _reflect_column Undocumented
Method _reflect_fk Undocumented
Method _reflect_indexes Undocumented
Method _reflect_pk Undocumented
Method _reflect_table_comment Undocumented
Method _reflect_unique_constraints Undocumented
Class Variable _index_sort_exprs Undocumented
Instance Variable _op_context_requires_connect Undocumented

Inherited from Inspectable:

Class Variable __slots__ Undocumented
@classmethod
@util.deprecated('1.4', 'The from_engine() method on :class:`_reflection.Inspector` is deprecated and will be removed in a future release. Please use the :func:`.sqlalchemy.inspect` function on an :class:`_engine.Engine` or :class:`_engine.Connection` in order to acquire an :class:`_reflection.Inspector`.')
def from_engine(cls, bind: Engine) -> Inspector: (source)

Construct a new dialect-specific Inspector object from the given engine or connection. :param bind: a :class:`~sqlalchemy.engine.Connection` or :class:`~sqlalchemy.engine.Engine`. This method differs from direct a direct constructor call of :class:`_reflection.Inspector` in that the :class:`~sqlalchemy.engine.interfaces.Dialect` is given a chance to provide a dialect-specific :class:`_reflection.Inspector` instance, which may provide additional methods. See the example at :class:`_reflection.Inspector`.

@util.deprecated('1.4', 'The __init__() method on :class:`_reflection.Inspector` is deprecated and will be removed in a future release. Please use the :func:`.sqlalchemy.inspect` function on an :class:`_engine.Engine` or :class:`_engine.Connection` in order to acquire an :class:`_reflection.Inspector`.')
def __init__(self, bind: Union[Engine, Connection]): (source)

Initialize a new :class:`_reflection.Inspector`. :param bind: a :class:`~sqlalchemy.engine.Connection`, which is typically an instance of :class:`~sqlalchemy.engine.Engine` or :class:`~sqlalchemy.engine.Connection`. For a dialect-specific instance of :class:`_reflection.Inspector`, see :meth:`_reflection.Inspector.from_engine`

def clear_cache(self): (source)

reset the cache for this :class:`.Inspector`. Inspection methods that have data cached will emit SQL queries when next called to get new data. .. versionadded:: 2.0

def get_check_constraints(self, table_name: str, schema: Optional[str] = None, **kw: Any) -> List[ReflectedCheckConstraint]: (source)

Return information about check constraints in ``table_name``. Given a string ``table_name`` and an optional string `schema`, return check constraint information as a list of :class:`.ReflectedCheckConstraint`. :param table_name: string name of the table. For special quoting, use :class:`.quoted_name`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a list of dictionaries, each representing the definition of a check constraints. .. versionadded:: 1.1.0 .. seealso:: :meth:`Inspector.get_multi_check_constraints`

def get_columns(self, table_name: str, schema: Optional[str] = None, **kw: Any) -> List[ReflectedColumn]: (source)

Return information about columns in ``table_name``. Given a string ``table_name`` and an optional string ``schema``, return column information as a list of :class:`.ReflectedColumn`. :param table_name: string name of the table. For special quoting, use :class:`.quoted_name`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: list of dictionaries, each representing the definition of a database column. .. seealso:: :meth:`Inspector.get_multi_columns`.

def get_foreign_keys(self, table_name: str, schema: Optional[str] = None, **kw: Any) -> List[ReflectedForeignKeyConstraint]: (source)

Return information about foreign_keys in ``table_name``. Given a string ``table_name``, and an optional string `schema`, return foreign key information as a list of :class:`.ReflectedForeignKeyConstraint`. :param table_name: string name of the table. For special quoting, use :class:`.quoted_name`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a list of dictionaries, each representing the a foreign key definition. .. seealso:: :meth:`Inspector.get_multi_foreign_keys`

def get_indexes(self, table_name: str, schema: Optional[str] = None, **kw: Any) -> List[ReflectedIndex]: (source)

Return information about indexes in ``table_name``. Given a string ``table_name`` and an optional string `schema`, return index information as a list of :class:`.ReflectedIndex`. :param table_name: string name of the table. For special quoting, use :class:`.quoted_name`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a list of dictionaries, each representing the definition of an index. .. seealso:: :meth:`Inspector.get_multi_indexes`

def get_materialized_view_names(self, schema: Optional[str] = None, **kw: Any) -> List[str]: (source)

Return all materialized view names in `schema`. :param schema: Optional, retrieve names from a non-default schema. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. .. versionadded:: 2.0 .. seealso:: :meth:`.Inspector.get_view_names`

def get_multi_check_constraints(self, schema: Optional[str] = None, filter_names: Optional[Sequence[str]] = None, kind: ObjectKind = ObjectKind.TABLE, scope: ObjectScope = ObjectScope.DEFAULT, **kw: Any) -> Dict[TableKey, List[ReflectedCheckConstraint]]: (source)

Return information about check constraints in all tables in the given schema. The tables can be filtered by passing the names to use to ``filter_names``. For each table the value is a list of :class:`.ReflectedCheckConstraint`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param filter_names: optionally return information only for the objects listed here. :param kind: a :class:`.ObjectKind` that specifies the type of objects to reflect. Defaults to ``ObjectKind.TABLE``. :param scope: a :class:`.ObjectScope` that specifies if constraints of default, temporary or any tables should be reflected. Defaults to ``ObjectScope.DEFAULT``. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a dictionary where the keys are two-tuple schema,table-name and the values are list of dictionaries, each representing the definition of a check constraints. The schema is ``None`` if no schema is provided. .. versionadded:: 2.0 .. seealso:: :meth:`Inspector.get_check_constraints`

def get_multi_columns(self, schema: Optional[str] = None, filter_names: Optional[Sequence[str]] = None, kind: ObjectKind = ObjectKind.TABLE, scope: ObjectScope = ObjectScope.DEFAULT, **kw: Any) -> Dict[TableKey, List[ReflectedColumn]]: (source)

Return information about columns in all objects in the given schema. The objects can be filtered by passing the names to use to ``filter_names``. For each table the value is a list of :class:`.ReflectedColumn`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param filter_names: optionally return information only for the objects listed here. :param kind: a :class:`.ObjectKind` that specifies the type of objects to reflect. Defaults to ``ObjectKind.TABLE``. :param scope: a :class:`.ObjectScope` that specifies if columns of default, temporary or any tables should be reflected. Defaults to ``ObjectScope.DEFAULT``. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a dictionary where the keys are two-tuple schema,table-name and the values are list of dictionaries, each representing the definition of a database column. The schema is ``None`` if no schema is provided. .. versionadded:: 2.0 .. seealso:: :meth:`Inspector.get_columns`

def get_multi_foreign_keys(self, schema: Optional[str] = None, filter_names: Optional[Sequence[str]] = None, kind: ObjectKind = ObjectKind.TABLE, scope: ObjectScope = ObjectScope.DEFAULT, **kw: Any) -> Dict[TableKey, List[ReflectedForeignKeyConstraint]]: (source)

Return information about foreign_keys in all tables in the given schema. The tables can be filtered by passing the names to use to ``filter_names``. For each table the value is a list of :class:`.ReflectedForeignKeyConstraint`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param filter_names: optionally return information only for the objects listed here. :param kind: a :class:`.ObjectKind` that specifies the type of objects to reflect. Defaults to ``ObjectKind.TABLE``. :param scope: a :class:`.ObjectScope` that specifies if foreign keys of default, temporary or any tables should be reflected. Defaults to ``ObjectScope.DEFAULT``. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a dictionary where the keys are two-tuple schema,table-name and the values are list of dictionaries, each representing a foreign key definition. The schema is ``None`` if no schema is provided. .. versionadded:: 2.0 .. seealso:: :meth:`Inspector.get_foreign_keys`

def get_multi_indexes(self, schema: Optional[str] = None, filter_names: Optional[Sequence[str]] = None, kind: ObjectKind = ObjectKind.TABLE, scope: ObjectScope = ObjectScope.DEFAULT, **kw: Any) -> Dict[TableKey, List[ReflectedIndex]]: (source)

Return information about indexes in in all objects in the given schema. The objects can be filtered by passing the names to use to ``filter_names``. For each table the value is a list of :class:`.ReflectedIndex`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param filter_names: optionally return information only for the objects listed here. :param kind: a :class:`.ObjectKind` that specifies the type of objects to reflect. Defaults to ``ObjectKind.TABLE``. :param scope: a :class:`.ObjectScope` that specifies if indexes of default, temporary or any tables should be reflected. Defaults to ``ObjectScope.DEFAULT``. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a dictionary where the keys are two-tuple schema,table-name and the values are list of dictionaries, each representing the definition of an index. The schema is ``None`` if no schema is provided. .. versionadded:: 2.0 .. seealso:: :meth:`Inspector.get_indexes`

def get_multi_pk_constraint(self, schema: Optional[str] = None, filter_names: Optional[Sequence[str]] = None, kind: ObjectKind = ObjectKind.TABLE, scope: ObjectScope = ObjectScope.DEFAULT, **kw: Any) -> Dict[TableKey, ReflectedPrimaryKeyConstraint]: (source)

Return information about primary key constraints in all tables in the given schema. The tables can be filtered by passing the names to use to ``filter_names``. For each table the value is a :class:`.ReflectedPrimaryKeyConstraint`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param filter_names: optionally return information only for the objects listed here. :param kind: a :class:`.ObjectKind` that specifies the type of objects to reflect. Defaults to ``ObjectKind.TABLE``. :param scope: a :class:`.ObjectScope` that specifies if primary keys of default, temporary or any tables should be reflected. Defaults to ``ObjectScope.DEFAULT``. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a dictionary where the keys are two-tuple schema,table-name and the values are dictionaries, each representing the definition of a primary key constraint. The schema is ``None`` if no schema is provided. .. versionadded:: 2.0 .. seealso:: :meth:`Inspector.get_pk_constraint`

def get_multi_table_comment(self, schema: Optional[str] = None, filter_names: Optional[Sequence[str]] = None, kind: ObjectKind = ObjectKind.TABLE, scope: ObjectScope = ObjectScope.DEFAULT, **kw: Any) -> Dict[TableKey, ReflectedTableComment]: (source)

Return information about the table comment in all objects in the given schema. The objects can be filtered by passing the names to use to ``filter_names``. For each table the value is a :class:`.ReflectedTableComment`. Raises ``NotImplementedError`` for a dialect that does not support comments. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param filter_names: optionally return information only for the objects listed here. :param kind: a :class:`.ObjectKind` that specifies the type of objects to reflect. Defaults to ``ObjectKind.TABLE``. :param scope: a :class:`.ObjectScope` that specifies if comments of default, temporary or any tables should be reflected. Defaults to ``ObjectScope.DEFAULT``. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a dictionary where the keys are two-tuple schema,table-name and the values are dictionaries, representing the table comments. The schema is ``None`` if no schema is provided. .. versionadded:: 2.0 .. seealso:: :meth:`Inspector.get_table_comment`

def get_multi_table_options(self, schema: Optional[str] = None, filter_names: Optional[Sequence[str]] = None, kind: ObjectKind = ObjectKind.TABLE, scope: ObjectScope = ObjectScope.DEFAULT, **kw: Any) -> Dict[TableKey, Dict[str, Any]]: (source)

Return a dictionary of options specified when the tables in the given schema were created. The tables can be filtered by passing the names to use to ``filter_names``. This currently includes some options that apply to MySQL and Oracle tables. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param filter_names: optionally return information only for the objects listed here. :param kind: a :class:`.ObjectKind` that specifies the type of objects to reflect. Defaults to ``ObjectKind.TABLE``. :param scope: a :class:`.ObjectScope` that specifies if options of default, temporary or any tables should be reflected. Defaults to ``ObjectScope.DEFAULT``. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a dictionary where the keys are two-tuple schema,table-name and the values are dictionaries with the table options. The returned keys in each dict depend on the dialect in use. Each one is prefixed with the dialect name. The schema is ``None`` if no schema is provided. .. versionadded:: 2.0 .. seealso:: :meth:`Inspector.get_table_options`

def get_multi_unique_constraints(self, schema: Optional[str] = None, filter_names: Optional[Sequence[str]] = None, kind: ObjectKind = ObjectKind.TABLE, scope: ObjectScope = ObjectScope.DEFAULT, **kw: Any) -> Dict[TableKey, List[ReflectedUniqueConstraint]]: (source)

Return information about unique constraints in all tables in the given schema. The tables can be filtered by passing the names to use to ``filter_names``. For each table the value is a list of :class:`.ReflectedUniqueConstraint`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param filter_names: optionally return information only for the objects listed here. :param kind: a :class:`.ObjectKind` that specifies the type of objects to reflect. Defaults to ``ObjectKind.TABLE``. :param scope: a :class:`.ObjectScope` that specifies if constraints of default, temporary or any tables should be reflected. Defaults to ``ObjectScope.DEFAULT``. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a dictionary where the keys are two-tuple schema,table-name and the values are list of dictionaries, each representing the definition of an unique constraint. The schema is ``None`` if no schema is provided. .. versionadded:: 2.0 .. seealso:: :meth:`Inspector.get_unique_constraints`

def get_pk_constraint(self, table_name: str, schema: Optional[str] = None, **kw: Any) -> ReflectedPrimaryKeyConstraint: (source)

Return information about primary key constraint in ``table_name``. Given a string ``table_name``, and an optional string `schema`, return primary key information as a :class:`.ReflectedPrimaryKeyConstraint`. :param table_name: string name of the table. For special quoting, use :class:`.quoted_name`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a dictionary representing the definition of a primary key constraint. .. seealso:: :meth:`Inspector.get_multi_pk_constraint`

def get_schema_names(self, **kw: Any) -> List[str]: (source)

Return all schema names. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information.

def get_sequence_names(self, schema: Optional[str] = None, **kw: Any) -> List[str]: (source)

Return all sequence names in `schema`. :param schema: Optional, retrieve names from a non-default schema. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information.

def get_sorted_table_and_fkc_names(self, schema: Optional[str] = None, **kw: Any) -> List[Tuple[Optional[str], List[Tuple[str, Optional[str]]]]]: (source)

Return dependency-sorted table and foreign key constraint names in referred to within a particular schema. This will yield 2-tuples of ``(tablename, [(tname, fkname), (tname, fkname), ...])`` consisting of table names in CREATE order grouped with the foreign key constraint names that are not detected as belonging to a cycle. The final element will be ``(None, [(tname, fkname), (tname, fkname), ..])`` which will consist of remaining foreign key constraint names that would require a separate CREATE step after-the-fact, based on dependencies between tables. .. versionadded:: 1.0.- :param schema: schema name to query, if not the default schema. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. .. seealso:: :meth:`_reflection.Inspector.get_table_names` :func:`.sort_tables_and_constraints` - similar method which works with an already-given :class:`_schema.MetaData`.

def get_table_comment(self, table_name: str, schema: Optional[str] = None, **kw: Any) -> ReflectedTableComment: (source)

Return information about the table comment for ``table_name``. Given a string ``table_name`` and an optional string ``schema``, return table comment information as a :class:`.ReflectedTableComment`. Raises ``NotImplementedError`` for a dialect that does not support comments. :param table_name: string name of the table. For special quoting, use :class:`.quoted_name`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a dictionary, with the table comment. .. versionadded:: 1.2 .. seealso:: :meth:`Inspector.get_multi_table_comment`

def get_table_names(self, schema: Optional[str] = None, **kw: Any) -> List[str]: (source)

Return all table names within a particular schema. The names are expected to be real tables only, not views. Views are instead returned using the :meth:`_reflection.Inspector.get_view_names` and/or :meth:`_reflection.Inspector.get_materialized_view_names` methods. :param schema: Schema name. If ``schema`` is left at ``None``, the database's default schema is used, else the named schema is searched. If the database does not support named schemas, behavior is undefined if ``schema`` is not passed as ``None``. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. .. seealso:: :meth:`_reflection.Inspector.get_sorted_table_and_fkc_names` :attr:`_schema.MetaData.sorted_tables`

def get_table_options(self, table_name: str, schema: Optional[str] = None, **kw: Any) -> Dict[str, Any]: (source)

Return a dictionary of options specified when the table of the given name was created. This currently includes some options that apply to MySQL and Oracle tables. :param table_name: string name of the table. For special quoting, use :class:`.quoted_name`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a dict with the table options. The returned keys depend on the dialect in use. Each one is prefixed with the dialect name. .. seealso:: :meth:`Inspector.get_multi_table_options`

def get_temp_table_names(self, **kw: Any) -> List[str]: (source)

Return a list of temporary table names for the current bind. This method is unsupported by most dialects; currently only Oracle, PostgreSQL and SQLite implements it. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. .. versionadded:: 1.0.0

def get_temp_view_names(self, **kw: Any) -> List[str]: (source)

Return a list of temporary view names for the current bind. This method is unsupported by most dialects; currently only PostgreSQL and SQLite implements it. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. .. versionadded:: 1.0.0

def get_unique_constraints(self, table_name: str, schema: Optional[str] = None, **kw: Any) -> List[ReflectedUniqueConstraint]: (source)

Return information about unique constraints in ``table_name``. Given a string ``table_name`` and an optional string `schema`, return unique constraint information as a list of :class:`.ReflectedUniqueConstraint`. :param table_name: string name of the table. For special quoting, use :class:`.quoted_name`. :param schema: string schema name; if omitted, uses the default schema of the database connection. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. :return: a list of dictionaries, each representing the definition of an unique constraint. .. seealso:: :meth:`Inspector.get_multi_unique_constraints`

def get_view_definition(self, view_name: str, schema: Optional[str] = None, **kw: Any) -> str: (source)

Return definition for the plain or materialized view called ``view_name``. :param view_name: Name of the view. :param schema: Optional, retrieve names from a non-default schema. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information.

def get_view_names(self, schema: Optional[str] = None, **kw: Any) -> List[str]: (source)

Return all non-materialized view names in `schema`. :param schema: Optional, retrieve names from a non-default schema. For special quoting, use :class:`.quoted_name`. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. .. versionchanged:: 2.0 For those dialects that previously included the names of materialized views in this list (currently PostgreSQL), this method no longer returns the names of materialized views. the :meth:`.Inspector.get_materialized_view_names` method should be used instead. .. seealso:: :meth:`.Inspector.get_materialized_view_names`

def has_index(self, table_name: str, index_name: str, schema: Optional[str] = None, **kw: Any) -> bool: (source)

Check the existence of a particular index name in the database. :param table_name: the name of the table the index belongs to :param index_name: the name of the index to check :param schema: schema name to query, if not the default schema. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. .. versionadded:: 2.0

def has_schema(self, schema_name: str, **kw: Any) -> bool: (source)

Return True if the backend has a schema with the given name. :param schema_name: name of the schema to check :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. .. versionadded:: 2.0

def has_sequence(self, sequence_name: str, schema: Optional[str] = None, **kw: Any) -> bool: (source)

Return True if the backend has a sequence with the given name. :param sequence_name: name of the sequence to check :param schema: schema name to query, if not the default schema. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. .. versionadded:: 1.4

def has_table(self, table_name: str, schema: Optional[str] = None, **kw: Any) -> bool: (source)

Return True if the backend has a table, view, or temporary table of the given name. :param table_name: name of the table to check :param schema: schema name to query, if not the default schema. :param \**kw: Additional keyword argument to pass to the dialect specific implementation. See the documentation of the dialect in use for more information. .. versionadded:: 1.4 - the :meth:`.Inspector.has_table` method replaces the :meth:`_engine.Engine.has_table` method. .. versionchanged:: 2.0:: :meth:`.Inspector.has_table` now formally supports checking for additional table-like objects: * any type of views (plain or materialized) * temporary tables of any kind Previously, these two checks were not formally specified and different dialects would vary in their behavior. The dialect testing suite now includes tests for all of these object types and should be supported by all SQLAlchemy-included dialects. Support among third party dialects may be lagging, however.

def reflect_table(self, table: sa_schema.Table, include_columns: Optional[Collection[str]], exclude_columns: Collection[str] = (), resolve_fks: bool = True, _extend_on: Optional[Set[sa_schema.Table]] = None, _reflect_info: Optional[_ReflectionInfo] = None): (source)

Given a :class:`_schema.Table` object, load its internal constructs based on introspection. This is the underlying method used by most dialects to produce table reflection. Direct usage is like:: from sqlalchemy import create_engine, MetaData, Table from sqlalchemy import inspect engine = create_engine('...') meta = MetaData() user_table = Table('user', meta) insp = inspect(engine) insp.reflect_table(user_table, None) .. versionchanged:: 1.4 Renamed from ``reflecttable`` to ``reflect_table`` :param table: a :class:`~sqlalchemy.schema.Table` instance. :param include_columns: a list of string column names to include in the reflection process. If ``None``, all columns are reflected.

def sort_tables_on_foreign_key_dependency(self, consider_schemas: Collection[Optional[str]] = (None), **kw: Any) -> List[Tuple[Optional[Tuple[Optional[str], str]], List[Tuple[Tuple[Optional[str], str], Optional[str]]]]]: (source)

Return dependency-sorted table and foreign key constraint names referred to within multiple schemas. This method may be compared to :meth:`.Inspector.get_sorted_table_and_fkc_names`, which works on one schema at a time; here, the method is a generalization that will consider multiple schemas at once including that it will resolve for cross-schema foreign keys. .. versionadded:: 2.0

Undocumented

Undocumented

info_cache: dict = (source)

Undocumented

@property
default_schema_name: Optional[str] = (source)

Return the default schema name presented by the dialect for the current engine's database user. E.g. this is typically ``public`` for PostgreSQL and ``dbo`` for SQL Server.

@classmethod
def _construct(cls, init: Callable[..., Any], bind: Union[Engine, Connection]) -> Inspector: (source)

Undocumented

Undocumented

Undocumented

def _get_reflection_info(self, schema: Optional[str] = None, filter_names: Optional[Collection[str]] = None, available: Optional[Collection[str]] = None, _reflect_info: Optional[_ReflectionInfo] = None, **kw: Any) -> _ReflectionInfo: (source)

Undocumented

def _init_connection(self, connection: Connection): (source)

Undocumented

def _init_engine(self, engine: Engine): (source)

Undocumented

def _init_legacy(self, bind: Union[Engine, Connection]): (source)

Undocumented

Return an :class:`_reflection.Inspector` from this one that will run all operations on a single connection.

def _instantiate_types(self, data: Iterable[List[ReflectedColumn]]): (source)

Undocumented

Return a context that optimizes for multiple operations on a single transaction. This essentially allows connect()/close() to be called if we detected that we're against an :class:`_engine.Engine` and not a :class:`_engine.Connection`.

def _reflect_check_constraints(self, _reflect_info: _ReflectionInfo, table_key: TableKey, table: sa_schema.Table, cols_by_orig_name: Dict[str, sa_schema.Column[Any]], include_columns: Optional[Collection[str]], exclude_columns: Collection[str], reflection_options: Dict[str, Any]): (source)

Undocumented

def _reflect_column(self, table: sa_schema.Table, col_d: ReflectedColumn, include_columns: Optional[Collection[str]], exclude_columns: Collection[str], cols_by_orig_name: Dict[str, sa_schema.Column[Any]]): (source)

Undocumented

def _reflect_fk(self, _reflect_info: _ReflectionInfo, table_key: TableKey, table: sa_schema.Table, cols_by_orig_name: Dict[str, sa_schema.Column[Any]], include_columns: Optional[Collection[str]], exclude_columns: Collection[str], resolve_fks: bool, _extend_on: Optional[Set[sa_schema.Table]], reflection_options: Dict[str, Any]): (source)

Undocumented

def _reflect_indexes(self, _reflect_info: _ReflectionInfo, table_key: TableKey, table: sa_schema.Table, cols_by_orig_name: Dict[str, sa_schema.Column[Any]], include_columns: Optional[Collection[str]], exclude_columns: Collection[str], reflection_options: Dict[str, Any]): (source)

Undocumented

def _reflect_pk(self, _reflect_info: _ReflectionInfo, table_key: TableKey, table: sa_schema.Table, cols_by_orig_name: Dict[str, sa_schema.Column[Any]], exclude_columns: Collection[str]): (source)

Undocumented

def _reflect_table_comment(self, _reflect_info: _ReflectionInfo, table_key: TableKey, table: sa_schema.Table, reflection_options: Dict[str, Any]): (source)

Undocumented

def _reflect_unique_constraints(self, _reflect_info: _ReflectionInfo, table_key: TableKey, table: sa_schema.Table, cols_by_orig_name: Dict[str, sa_schema.Column[Any]], include_columns: Optional[Collection[str]], exclude_columns: Collection[str], reflection_options: Dict[str, Any]): (source)

Undocumented

_index_sort_exprs = (source)

Undocumented

_op_context_requires_connect: bool = (source)

Undocumented