MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / get_schema_object_by_name

Method get_schema_object_by_name

lib/sqlalchemy/sql/schema.py:6387–6411  ·  view source on GitHub ↗

Return a schema objects of the given kind and name if found. This method can be used to return :class:`_sqltypes.Enum`, :class:`.Sequence`, etc. objects registered in this :class:`_schema.MetaData`. :param kind: a type that indicates what object to return, such as

(
        self,
        kind: Type[_T],
        name: str,
        *,
        schema: Union[str, None, Literal[_NoArg.NO_ARG]] = _NoArg.NO_ARG,
    )

Source from the content-addressed store, hash-verified

6385 )
6386
6387 def get_schema_object_by_name(
6388 self,
6389 kind: Type[_T],
6390 name: str,
6391 *,
6392 schema: Union[str, None, Literal[_NoArg.NO_ARG]] = _NoArg.NO_ARG,
6393 ) -> Optional[_T]:
6394 """Return a schema objects of the given kind and name if found.
6395
6396 This method can be used to return :class:`_sqltypes.Enum`,
6397 :class:`.Sequence`, etc. objects registered in this
6398 :class:`_schema.MetaData`.
6399
6400 :param kind: a type that indicates what object to return, such as
6401 :class:`Enum` or :class:`Sequence`.
6402 :param name: the name of the object to return.
6403 :param schema: Optional, a schema name to filter the objects by. If
6404 not provided the default schema of the metadata is used.
6405
6406 """
6407
6408 for obj in self.get_schema_objects(kind, schema=schema):
6409 if getattr(obj, "name", None) == name:
6410 return obj
6411 return None
6412
6413 def _register_object(self, obj: Union[HasSchemaAttr, SchemaType]) -> None:
6414 self._objects.add(obj)

Callers 2

Calls 1

get_schema_objectsMethod · 0.95

Tested by 2