(conn, sleep_interval: int, table_name: str)
Delete table table_name
Delete table table_name
Delete table table_name
def delete_table(conn, sleep_interval: int, table_name: str):
    """
    Delete table table_name
    """

    if not args.dataOnly:
        if not args.noConfirm:
            confirmation = input(
                "About to delete table {}. Type 'yes' to continue: ".format(table_name)
            )
            if confirmation != "yes":
                logging.warn("Confirmation not received. Stopping.")
                sys.exit(1)
        while True:
            # delete table if exists
            table_exist = True
            try:
                conn.delete_table(TableName=table_name)
            except conn.exceptions.ResourceNotFoundException:
                table_exist = False
                logging.info(table_name + " table deleted!")
                break
            except conn.exceptions.LimitExceededException:
                logging.info(
                    "Limit exceeded, retrying deletion of " + table_name + ".."
                )
                time.sleep(sleep_interval)
            except conn.exceptions.ProvisionedThroughputExceededException:
                logging.info(
                    "Control plane limit exceeded, retrying deletion of "
                    + table_name
                    + ".."
                )
                time.sleep(sleep_interval)
            except conn.exceptions.ResourceInUseException:
                logging.info(table_name + " table is being deleted..")
                time.sleep(sleep_interval)
            except conn.exceptions.ClientError as e:
                logging.exception(e)
                sys.exit(1)

        # if table exists, wait till deleted
        if table_exist:
            try:
                while True:
                    logging.info(
                        "Waiting for "
                        + table_name
                        + " table to be deleted.. ["
                        + conn.describe_table(table_name)["Table"]["TableStatus"]
                        + "]"
                    )
                    time.sleep(sleep_interval)
            except conn.exceptions.ResourceNotFoundException:
                logging.info(table_name + " table deleted.")
                pass
            except conn.exceptions.ClientError as e:
                logging.exception(e)
                sys.exit(1)
def delete_table ( conn , sleep_interval : int , table_name : str ) : if not args . dataOnly : if not args . noConfirm : confirmation = input ( "About to delete table {}. Type 'yes' to continue: " . format ( table_name ) ) if confirmation != "yes" : logging . warn ( "Confirmation not received. Stopping." ) sys . exit ( 1 ) while True : # delete table if exists table_exist = True try : conn . delete_table ( TableName = table_name ) except conn . exceptions . ResourceNotFoundException : table_exist = False logging . info ( table_name + " table deleted!" ) break except conn . exceptions . LimitExceededException : logging . info ( "Limit exceeded, retrying deletion of " + table_name + ".." ) time . sleep ( sleep_interval ) except conn . exceptions . ProvisionedThroughputExceededException : logging . info ( "Control plane limit exceeded, retrying deletion of " + table_name + ".." ) time . sleep ( sleep_interval ) except conn . exceptions . ResourceInUseException : logging . info ( table_name + " table is being deleted.." ) time . sleep ( sleep_interval ) except conn . exceptions . ClientError as e : logging . exception ( e ) sys . exit ( 1 ) # if table exists, wait till deleted if table_exist : try : while True : logging . info ( "Waiting for " + table_name + " table to be deleted.. [" + conn . describe_table ( table_name ) [ "Table" ] [ "TableStatus" ] + "]" ) time . sleep ( sleep_interval ) except conn . exceptions . ResourceNotFoundException : logging . info ( table_name + " table deleted." ) pass except conn . exceptions . ClientError as e : logging . exception ( e ) sys . exit ( 1 )