- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use Boto3 to get the details of all classifiers available in AWS Glue Data catalog?
Problem Statement: Use boto3 library in Python to get details of all classifiers present in AWS Glue Data catalog. For example, get the details of all classifier from user’s account.
Approach/Algorithm to solve this problem
Step 1 − Import boto3 and botocore exceptions to handle exceptions.
Step 2 − There is no parameter.
Step 3 − Create an AWS session using boto3 library. 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 AWS client for glue.
Step 5 − Call get_classifiers.
Step 6 − It will fetch details of all classifier available in AWS Glue Data Catalog.
Step 7 − Handle the generic exception if something went wrong while checking the job.
Example
Use the following code to get the details of all classifiers present in AWS Glue Data catalog −
import boto3 from botocore.exceptions import ClientError def get_all_classifier_details(): session = boto3.session.Session() glue_client = session.client('glue') try: response = glue_client.get_classifiers() return response except ClientError as e: raise Exception("boto3 client error in get_all_classifier_details: " + e.__str__()) except Exception as e: raise Exception("Unexpected error in get_all_classifier_details: " + e.__str__()) print(get_all_classifier_details())
Output
{'Classifiers': [ {'XMLClassifier': {'Name': 'aiml-linkup', 'Classification': 'xml', 'CreationTime': datetime.datetime(2020, 4, 17, 13, 26, 50, tzinfo=tzlocal()), 'LastUpdated': datetime.datetime(2020, 4, 17, 13, 26, 50, tzinfo=tzlocal()), 'Version': 1, 'RowTag': 'job'}}, {'XMLClassifier': {'Name': 'aiml-test1', 'Classification': 'xml', 'CreationTime': datetime.datetime(2019, 10, 7, 20, 48, 44, tzinfo=tzlocal()), 'LastUpdated': datetime.datetime(2019, 10, 7, 20, 48, 44, tzinfo=tzlocal()), 'Version': 1, 'RowTag': 'nitf'}}, {'GrokClassifier': {'Name': 'classifier1', 'Classification': 'classifier1', 'CreationTime': datetime.datetime(2018, 6, 21, 4, 7, 4, tzinfo=tzlocal()), 'LastUpdated': datetime.datetime(2018, 6, 21, 4, 7, 11, tzinfo=tzlocal()), 'Version': 2, 'GrokPattern': 'SYSLOGTIMESTAMP %{MONTH} +%{MONTHDAY} %{TIME}'}}, {'CsvClassifier': {'Name': 'csvquotes', 'CreationTime': datetime.datetime(2020, 9, 10, 5, 6, 29, tzinfo=tzlocal()), 'LastUpdated': datetime.datetime(2020, 9, 10, 5, 6, 29, tzinfo=tzlocal()), 'Version': 1, 'Delimiter': ',', 'QuoteSymbol': '"', 'ContainsHeader': 'UNKNOWN', 'DisableValueTrimming': False, 'AllowSingleColumn': False}}, {'XMLClassifier': {'Name': 'xml-test', 'Classification': 'xml', 'CreationTime': datetime.datetime(2020, 4, 10, 18, 26, 50, tzinfo=tzlocal()), 'LastUpdated': datetime.datetime(2020, 4, 15, 0, 3, 8, tzinfo=tzlocal()), 'Version': 2, 'RowTag': 'job'}}], 'ResponseMetadata': {'RequestId': '7fa7a78e-…………e4261bfd1', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Sun, 21 Feb 2021 08:02:30 GMT', 'content-type': 'application/x-amz-json-1.1', 'contentlength': '885', 'connection': 'keep-alive', 'x-amzn-requestid': '7fa7a78e-……………..e4261bfd1'}, 'RetryAttempts': 0}}
- Related Articles
- How to use Boto3 to get the details of all connection available in AWS Glue Data catalog?
- How to use Boto3 get the details of all the databases from AWS Glue Data Catalog?
- How to use Boto3 to get the details of a classifier from AWS Glue Data catalog?
- How to use Boto3 to get the details of a connection from AWS Glue Data catalog?
- How to use Boto3 to get the details of a database from AWS Glue Data Catalog?
- How to get the details of a trigger from AWS Glue Data catalog using Boto3
- How to use Boto3 to get the details of a job that is bookmarked in AWS Glue Data Catalog?
- How to use Boto3 to update the details of a workflow in AWS Glue Catalog
- How to get the details of all the triggers associated with a job from AWS Glue Data catalog using Boto3
- How to use Boto3 to get the security configuration/encryption settings of a catalog from AWS Glue Data Catalog?
- How to use Boto3 to start a crawler in AWS Glue Data Catalog
- How to use Boto3 to start a trigger in AWS Glue Data Catalog
- How to use Boto3 to stop a trigger in AWS Glue Data Catalog
- How to use Boto3 to start a workflow in AWS Glue Data Catalog
- How to use Boto3 to stop a workflow in AWS Glue Data Catalog
