【问题标题】:Extract data from AWS Glue Data Catalog to a text file externally将数据从 AWS Glue 数据目录提取到外部文本文件
【发布时间】:2019-11-11 13:05:54
【问题描述】:

我正在编写一个 python 脚本,它应该读取 AWS Glue 数据目录中存在的元数据(仅模式)并将其写入文本文件。 这个怎么办?

【问题讨论】:

  • 请添加您的python脚本并为问题添加更多详细信息,您要阅读的胶水目录中到底有什么

标签: amazon-web-services aws-glue aws-glue-data-catalog


【解决方案1】:

您可以使用 boto3 python api 从粘合目录中查询表元数据。

示例代码:

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

您可以解析响应 (json) 以提取所需的元数据并将其转储到文件中。

参考文档:Boto3 - Glue Catalog - Get Table

【讨论】:

  • 得到错误:botocore.errorfactory.EntityNotFoundException:调用GetTable操作时发生错误(EntityNotFoundException):找不到数据库sampledb。你能告诉我如何成功运行吗
  • 错误信息明确指出在您的胶水目录中没有名为 sampledb 的数据库。你能验证一下吗?
  • 是的,没有名为 sampledb 的数据库。非常感谢:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-20
  • 1970-01-01
  • 2014-05-11
相关资源
最近更新 更多