- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 a database from AWS Glue Data Catalog?
Problem Statement − Use boto3 library in Python to retrieve the definition of a database.
Example − Retrieve the definition of a database ‘QA-test’.
Approach/Algorithm to solve this problem
Step 1 − Import boto3 and botocore exceptions to handle exceptions.
Step 2 − database_name is the mandatory parameter. It fetches definition of given database.
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 − Now use get_database function and pass the database_name as Name parameter.
Step 6 − It returns the definition of a given database.
Step 7 − Handle the generic exception if something went wrong while checking the job.
Example
Use the following code to retrieve the definition of a database −
import boto3 from botocore.exceptions import ClientError def retrieves_database_details(database_name) session = boto3.session.Session() glue_client = session.client('glue') try: response = glue_client.get_database(Name = database_name) return response except ClientError as e: raise Exception("boto3 client error in retrieves_database_details: " + e.__str__()) except Exception as e: raise Exception("Unexpected error in retrieves_database_details: " + e.__str__()) print(retrieves_database_details('QA-test'))
- Related Articles
- 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 get the details of all the databases 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 table definition of a database from AWS Glue Data Catalog?
- How to get the details of a user-defined function in a database from AWS Glue Data catalog using Boto3
- How to use Boto3 to get the details of all classifiers available in AWS Glue Data catalog?
- How to use Boto3 to get the details of all connection available in AWS Glue Data catalog?
- How to use Boto3 to get the specified version table definition of a database from AWS Glue Data Catalog?
- How to use Boto3 to get the details of a job that is bookmarked in AWS Glue Data Catalog?
- How to get the table definition in a database 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 update the details of a workflow in AWS Glue Catalog
- How to use Boto3 to delete a crawler from AWS Glue Data Catalog?
- How to use Boto3 to delete a table from AWS Glue Data catalog?
