সমস্যা বিবরণ: Python-এ boto3 লাইব্রেরি ব্যবহার করে AWS Glue Data Catalog-এ থাকা সব ক্লাসিফায়ারের ডিটেইলস পাওয়া। উদাহরণস্বরূপ, ইউজারের অ্যাকাউন্ট থেকে সব ক্লাসিফায়ারের ডিটেইলস পাওয়া।
সমাধানের পদ্ধতি/অ্যালগরিদম
ধাপ ১ − boto3 এবং botocore এক্সসেপশন ইম্পোর্ট করে এক্সসেপশন হ্যান্ডল করা।
ধাপ ২ − কোনো প্যারামিটার নেই।
ধাপ ৩ − boto3 লাইব্রেরি ব্যবহার করে AWS সেশন তৈরি করা। নিশ্চিত করুন region_name ডিফল্ট প্রোফাইলে ذکر করা আছে। না থাকলে সেশন তৈরি করার সময় স্পষ্টভাবে region_name পাস করুন।
ধাপ ৪ − Glue-এর জন্য AWS ক্লায়েন্ট তৈরি করা।
ধাপ ৫ − get_classifiers কল করা।
ধাপ ৬ − এটি AWS Glue Data Catalog-এ উপলব্ধ সব ক্লাসিফায়ারের ডিটেইলস আনয়ন করবে।
ধাপ ৭ − জব চেক করার সময় যদি কিছু ভুল হয় তবে জেনেরিক এক্সসেপশন হ্যান্ডল করা।
উদাহরণ
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())আউটপুট
{'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}}