使用 Glue 从 AWS RDS 到 S3 的管道

Pipeline from AWS RDS to S3 using Glue

我正在尝试 AWS Glue 将我们当前的数据管道从 python 脚本迁移到 AWS Glue。我能够设置一个爬虫来拉取不同 postgres 数据库的架构。但是,我在将数据从 Postgres RDS 提取到 Athena 中的 S3 表时遇到问题。

提前致谢!

您无法使用 Athena 将数据从 AWS RDS 提取到 S3。 Athena 是一个基于 S3 数据的查询引擎。为了能够将数据从 RDS 提取到 S3,您可以 运行 从特定 RDS table 读取的 Glue 作业并创建镶木地板格式的 S3 转储,这将创建另一个外部 table 指向到 S3 数据。然后您可以使用 Athena 查询该 S3 数据。使用 Glue 目录从 RDS 读取并在 S3 中写入 parquet 的示例代码片段如下所示。您可以使用一些 Glue 预定义模板进行实验。先从小 table 开始。请让我知道它是否适合您或进一步 questions/issues。

datasource0 = glueContext.create_dynamic_frame.from_options(connection_type="postgresql", connection_options = 
{"url": "jdbc-url/database",
"user": "user_name",
"password": "password",
"dbtable": "table_name"},
transformation_ctx = "datasource0")

   datasink4 = glueContext.write_dynamic_frame.from_options(frame = datasource0, connection_type = "s3", connection_options = {"path": "s3://aws-glue-tpcds-parquet/"+ tableName + "/"}, format = "parquet", transformation_ctx = "datasink4")