【发布时间】:2021-12-27 00:43:40
【问题描述】:
根据these AWS Amazon RDS docs,AWS 似乎提供了一个aws_s3 PostgreSQL 扩展,用于将数据从 S3 传输到 RDS 中的 Postgres。
我们正在使用气流来编排我们的数据摄取管道,如果这里有 python 解决方案那就太好了。我对 PostgreSQL 几乎没有经验,而且我从未使用过任何 PostgreSQL 扩展,并且能够使用 python 移动数据将对我们有很大帮助。目前,我们正在避免使用 AWS Data Pipeline 和 AWS Glue 等 AWS 工具,转而使用 python 和气流构建我们自己的架构。
作为参考,我们有以下 GCP 架构,用于使用 python 将 GCS 中的数据提取到 BigQuery 中:
from google.cloud import bigquery
# create BiqQuery client object + load job config
client = bigquery.Client()
job_config = bigquery.LoadJobConfig(
schema=None, # autodetech for now
source_format=bigquery.SourceFormat.NEWLINE_DELIMITED_JSON, # use ndjson
write_disposition=bigquery.WriteDisposition.WRITE_APPEND, # append to existing
autodetect=True
)
# and load into Bigquery
table_id = "our_gcp_project.our_model.our_table"
gcs_uri = "gs://our_bucket/path-to-our/file.json"
load_job = client.load_table_from_uri(gcs_uri, table_id, job_config=job_config) # location="US" # Make an API request.
load_job.result() # Waits for the job to complete
# check for success
destination_table = client.get_table(table_id)
print("Loaded {} rows.".format(destination_table.num_rows))
我们非常希望将此代码从 GCS/BigQuery 移植到 S3/Postgres RDS,并希望朝着正确的方向开始。
【问题讨论】:
-
S3/Redshift 看起来更适合与 GCS/BigQuery 等效。您可以使用 SQL 命令将数据从 S3 摄取到 Redshift。
-
您认为 Redshift 和 Postgres 之间的区别是什么?
-
Postgres 是一个事务性 SQL 数据库。 Redshift 是一个数据仓库,类似于 BigQuery。您不应该期望能够使用 Postgres 处理大数据。
-
我们使用 postgres 是因为我们需要将此数据库连接到我们的 Web 应用程序,以便在我们的 Web 应用程序上展示数据。 (与我们的 bigquery 数据库不同,)这不适用于大数据分析。
标签: python postgresql amazon-web-services amazon-s3 amazon-rds