- 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 list of schemas present in AWS account
In this article, we will see how a user can get the list of all schemas present in an AWS account.
Example
Get the list of all the schemas available in an AWS Glue Data Catalog.
Problem Statement: Use boto3 library in Python to get the list of all schemas.
Approach/Algorithm to solve this problem
Step 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 AWS client for glue.
Step 5: Now use list_schemas function
Step 6: It returns the list of all schemas present in the AWS Glue data catalog with limited details of schema. It doesn't include the schemas whose status is Deleting. It only has the list of available schemas. If there are no schemas, then it returns an empty dict.
Step 7: Handle the generic exception if something went wrong while checking the schemas.
Example Code
The following code fetches the list of all schemas −
import boto3 from botocore.exceptions import ClientError def list_of_schemas() session = boto3.session.Session() glue_client = session.client('glue') try: schemas_name = glue_client.list_schemas() return schemas_name except ClientError as e: raise Exception("boto3 client error in list_of_schemas: " + e.__str__()) except Exception as e: raise Exception("Unexpected error in list_of_schemas: " + e.__str__()) print(list_of_schemas())
Output
{ 'Schemas':[ { 'RegistryName': 'employee_details', 'SchemaName': 'employee_table', 'SchemaArn': 'string', 'Description': 'Schema for employees record', 'Status': 'AVAILABLE', 'CreatedTime': 'string', 'UpdatedTime': 'string' }, { 'RegistryName': 'security_details', 'SchemaName': 'security_table', 'SchemaArn': 'string', 'Description': 'Schema for security record', 'Status': 'AVAILABLE', 'CreatedTime': 'string', 'UpdatedTime': 'string' }, ], 'Request': …… }
- Related Articles
- How to use Boto3 to get the list of triggers present in an AWS account
- How to use Boto3 to get the list of workflows present an in AWS account
- How to get the list of all crawlers present in an AWS account using Boto3
- How to get the list of all registries present in an AWS account using Boto3
- How to use Boto3 library in Python to get the list of buckets present in AWS S3?
- How to use Boto3 to get a list of buckets present in S3 using AWS Client?
- How to use Boto3 to reset the bookmark of job in AWS account
- How to use Boto3 to get the details of allsecurity configuration present in AWS Glue Security?
- How to use Boto3 to get a list of all secrets in AWS Secret Manager
- How to use Boto3 to get the details of a specified security configuration present in AWS Glue Security?
- How to use Boto3 to paginate through all crawlers present in AWS Glue
- How to use Boto3 to paginate through all jobs present in AWS Glue
- How to use Boto3 to paginate through security configuration present in AWS Glue
- How to use Boto3 to paginate through all tables present in AWS Glue
- How to use Boto3 to paginate through all triggers present in AWS Glue
