awswrangler.catalog.delete_table_if_exists

awswrangler.catalog.delete_table_if_exists(database: str, table: str, catalog_id: str | None = None, boto3_session: Session | None = None) bool

Delete Glue table if exists.

Note

This function has arguments which can be configured globally through wr.config or environment variables:

  • catalog_id

  • database

Check out the Global Configurations Tutorial for details.

Parameters:
  • database (str) – Database name.

  • table (str) – Table name.

  • catalog_id (str, optional) – The ID of the Data Catalog from which to retrieve Databases. If none is provided, the AWS account ID is used by default.

  • boto3_session (boto3.Session(), optional) – Boto3 Session. The default boto3 session will be used if boto3_session receive None.

Returns:

True if deleted, otherwise False.

Return type:

bool

Examples

>>> import awswrangler as wr
>>> wr.catalog.delete_table_if_exists(database='default', table='my_table')  # deleted
True
>>> wr.catalog.delete_table_if_exists(database='default', table='my_table')  # Nothing to be deleted
False