Found 10476 Articles for Python

How to use Boto3 to start a trigger in AWS Glue Data Catalog

Ashish Anand
Updated on 15-Apr-2021 13:00:51

559 Views

In this article, we will see how a user can start a trigger in AWS Glue Data Catalog.ExampleProblem Statement: Use boto3 library in Python to start a trigger.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: trigger_name is the parameter in this function.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.Step 4: Create an AWS client for glue.Step 5: Now use the start_trigger function and pass the parameter trigger_name as Name.Step ... Read More

How to use Boto3 to start the scheduler of a crawler in AWS Glue Data Catalog

Ashish Anand
Updated on 15-Apr-2021 12:55:26

232 Views

In this article, we will see how a user can start the scheduler of a crawler in AWS Glue Data Catalog.ExampleStart the scheduler of a crawler available in AWS Glue Data Catalog. Problem Statement: Use boto3 library in Python to start the scheduler of a crawler.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: crawler_name is the required parameter in this function.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.Step 4: Create ... Read More

How to use Boto3 to stop the scheduler of a crawler in AWS Glue Data Catalog

Ashish Anand
Updated on 15-Apr-2021 12:54:53

138 Views

In this article, we will see how a user can stop the scheduler of a crawler present in an AWS Glue Data Catalog.ExampleStop the scheduler of a crawler available in an AWS Glue Data Catalog.Problem Statement: Use boto3 library in Python to stop the scheduler of a crawler.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: crawler_name is the required parameter in this function.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass the region_name while creating the ... Read More

How to use Boto3 to start a crawler in AWS Glue Data Catalog

Ashish Anand
Updated on 15-Apr-2021 12:54:32

2K+ Views

In this article, we will see how a user can start a crawler in AWS Glue Data Catalog.ExampleProblem Statement: Use boto3 library in Python to start a crawler.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptionsStep 2: crawler_name is the parameter in this function.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.Step 4: Create an AWS client for glue.Step 5: Now use the start_crawler function and pass the parameter crawler_name as Name.Step ... Read More

How to use Boto3 to reset the bookmark of job in AWS account

Ashish Anand
Updated on 15-Apr-2021 12:54:11

642 Views

In this article, we will see how a user can reset the bookmark of a job present in ann AWS account.ExampleReset the bookmark of a job available in an AWS Glue Data Catalog.Problem Statement: Use boto3 library in Python to reset the bookmark of a job.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: job_name is the parameter in this function.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.Step 4: Create ... Read More

How to use Boto3 to get the list of workflows present an in AWS account

Ashish Anand
Updated on 15-Apr-2021 12:53:51

246 Views

In this article, we will see how a user can get the list of all workflows present in an AWS account.ExampleGet the list of all workflows available in an AWS Glue Data Catalog.Problem Statement: Use boto3 library in Python to get the list of all workflows.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: There are no parameters in this function.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.Step 4: Create an ... Read More

Python program to unique keys count for Value in Tuple List

AmitDiwan
Updated on 15-Apr-2021 12:58:40

166 Views

When it is required to get the count of unique keys for values in a list of tuple, it can be iterated over and the respective counts can be determined.Below is a demonstration of the same −Example Live Demoimport collections my_result = collections.defaultdict(int) my_list = [[('Hello', 'Hey')], [('Jane', 'Will')], [('William', 'John')], [('Hello', 'Hey')], [('z', 'q')]] print("The list of list is :") print(my_list) for elem in my_list:    my_result[elem[0]] += 1 print("The result is : ") print(my_result)OutputThe list of list is : [[('Hello', 'Hey')], [('Jane', 'Will')], [('William', 'John')], [('Hello', 'Hey')], [('z', 'q')]] The result is : defaultdict(, {('Hello', 'Hey'): 2, ('Jane', ... Read More

Python program to count Bidirectional Tuple Pairs

AmitDiwan
Updated on 15-Apr-2021 12:58:16

193 Views

When it is required to count the number of bidirectional tuple pairs in a list of tuples, the list can be iterated over using nested loops, and the ‘AND’ operation is performed on the first element and result of equality between first and second element.Below is a demonstration of the same −Example Live Demomy_list = [(45, 67), (11, 23), (67, 45), (23, 11), (0, 9), (67, 45)] print("The list is : ") print(my_list) my_result = 0 for idx in range(0, len(my_list)):    for iidx in range(idx + 1, len(my_list)):       if my_list[iidx][0] == my_list[idx][1] and my_list[idx][1] == ... Read More

Python Program to Find the Sum of all Nodes in a Tree

AmitDiwan
Updated on 15-Apr-2021 12:57:57

415 Views

When it is required to get the sum of all the nodes in a Tree, a ‘Tree_structure’ class is created, methods to set a root value, and to add other values are defined. It also has a method to determine the sum of all elements of a Tree structure. Various options are given that the user can select. Based on the user’s choice, the operation is performed on the Tree elements.Below is a demonstration of the same −Example Live Democlass Tree_structure:    def __init__(self, data=None):       self.key = data       self.children = []    def set_root(self, ... Read More

Python Program to Count Number of Non Leaf Nodes of a given Tree

AmitDiwan
Updated on 15-Apr-2021 12:53:32

220 Views

When it is required to find the count of the non leaf nodes in a Tree, a ‘Tree_structure’ class is created, methods to set a root value, and to add other values are defined. Various options are given that the user can select. Based on the user’s choice, the operation is performed on the Tree elements.Below is a demonstration of the same −Example Live Democlass Tree_structure:    def __init__(self, data=None):       self.key = data       self.children = []    def set_root(self, data):       self.key = data    def add_vals(self, node):       ... Read More

Advertisements