DishaK
DishaK

Reputation: 23

Extract data from AWS Glue Data Catalog to a text file externally

I am writing a python script which should read metadata (only the schema) present in AWS Glue Data Catalog and write it to text files. How to go about this?

Upvotes: 2

Views: 4209

Answers (1)

Harsh Bafna
Harsh Bafna

Reputation: 2224

You can use the boto3 python api for querying the table metadata from glue catalog.

Sample code:

import boto3
client = boto3.client('glue')
response = client.get_table(
    DatabaseName='<your_database_name>',
    Name='<your_table_name>'
)
print response

You can parse to response (json) to extract the required metadata and dump it to file.

Reference documentation: Boto3 - Glue Catalog - Get Table

Upvotes: 2

Related Questions