Search code examples
amazon-web-servicesaws-glueaws-glue-data-catalog

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?


Solution

  • 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