Skip to content

list_databases

list_databases(
    catalog_name: CatalogNameString,
    *,
    config_overrides: Optional[AthenaClientConfig] = None,
    next_token: Optional[Token] = None,
    max_results: Optional[MaxDatabasesCount] = None,
    work_group: Optional[WorkGroupName] = None,
    attributes_to_get: Optional[DatabaseAttributesList] = None,
) -> ListDatabasesOutput

Lists the databases in the specified data catalog.

Parameters:

  • catalog_name (CatalogNameString) –

    The name of the data catalog that contains the databases to return.

  • next_token (Optional[Token], default: None ) –

    A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated. To obtain the next set of pages, pass in the NextToken from the response object of the previous page call.

  • max_results (Optional[MaxDatabasesCount], default: None ) –

    Specifies the maximum number of results to return.

  • work_group (Optional[WorkGroupName], default: None ) –

    The name of the workgroup for which the metadata is being fetched. Required if requesting an IAM Identity Center enabled Glue Data Catalog.

  • attributes_to_get (Optional[DatabaseAttributesList], default: None ) –

    Specifies the database properties returned by the ListDatabases call. The only valid value is NAME, which returns only the name of each database and omits the remaining properties. If you omit this parameter or specify an empty list, all database properties are returned.

    Requesting only names can reduce response time for catalogs that contain many databases, especially resource links to databases shared from other accounts.

    This parameter applies only to the Glue Data Catalog. For other data catalog types, it is ignored.

Raises:

  • InternalServerException –

    Indicates a platform issue, which may be due to a transient condition or outage.

  • InvalidRequestException –

    Indicates that something is wrong with the input to the request. For example, a required parameter may be missing or out of range.

  • MetadataException –

    An exception that Athena received when it called a custom metastore. Occurs if the error is not caused by user input (InvalidRequestException) or from the Athena platform (InternalServerException). For example, if a user-created Lambda function is missing permissions, the Lambda 4XX exception is returned in a MetadataException.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_athena/_services/athena.py
def list_databases(
    self,
    catalog_name: "capo_athena.types.catalog_name_string.CatalogNameString",
    *,
    config_overrides: Optional[AthenaClientConfig] = None,
    next_token: Optional["capo_athena.types.token.Token"] = None,
    max_results: Optional[
        "capo_athena.types.max_databases_count.MaxDatabasesCount"
    ] = None,
    work_group: Optional["capo_athena.types.work_group_name.WorkGroupName"] = None,
    attributes_to_get: Optional[
        "capo_athena.types.database_attributes_list.DatabaseAttributesList"
    ] = None,
) -> "capo_athena.types.list_databases_output.ListDatabasesOutput":
    """<p>Lists the databases in the specified data catalog.</p>

    Args:
        catalog_name: <p>The name of the data catalog that contains the databases to return.</p>
        next_token: <p>A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated. To obtain the next set of pages, pass in the <code>NextToken</code> from the response object of the previous page call.</p>
        max_results: <p>Specifies the maximum number of results to return.</p>
        work_group: <p>The name of the workgroup for which the metadata is being fetched. Required if requesting an IAM Identity Center enabled Glue Data Catalog.</p>
        attributes_to_get: <p>Specifies the database properties returned by the <code>ListDatabases</code> call. The only valid value is <code>NAME</code>, which returns only the name of each database and omits the remaining properties. If you omit this parameter or specify an empty list, all database properties are returned.</p> <p>Requesting only names can reduce response time for catalogs that contain many databases, especially resource links to databases shared from other accounts.</p> <p>This parameter applies only to the Glue Data Catalog. For other data catalog types, it is ignored.</p>

    Raises:
        capo_athena.errors.internal_server_exception.InternalServerException: <p>Indicates a platform issue, which may be due to a transient condition or outage.</p>
        capo_athena.errors.invalid_request_exception.InvalidRequestException: <p>Indicates that something is wrong with the input to the request. For example, a required parameter may be missing or out of range.</p>
        capo_athena.errors.metadata_exception.MetadataException: <p>An exception that Athena received when it called a custom metastore. Occurs if the error is not caused by user input (<code>InvalidRequestException</code>) or from the Athena platform (<code>InternalServerException</code>). For example, if a user-created Lambda function is missing permissions, the Lambda <code>4XX</code> exception is returned in a <code>MetadataException</code>.</p>
        capo_athena.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_athena.types.list_databases_input.ListDatabasesInput]",
    ) -> OperationResponse[
        "capo_athena.types.list_databases_output.ListDatabasesOutput"
    ]:
        import capo_athena._operations.amazon_athena.list_databases

        output, http_response = (
            capo_athena._operations.amazon_athena.list_databases.list_databases(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListDatabases")
    )
    input_: capo_athena.types.list_databases_input.ListDatabasesInput = {
        "catalog_name": catalog_name
    }
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results
    if work_group is not None:
        input_["work_group"] = work_group
    if attributes_to_get is not None:
        input_["attributes_to_get"] = attributes_to_get

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output