AWSGlueStudio中的RDS导向Redshift时,出现无效的时间戳格式错误
创始人
2024-09-25 16:31:05
0

您可以在导入数据时使用aws_glue.Template.athena_cleanup函数删除无效的时间戳格式。以下是示例代码:

import datetime
import boto3
import json
import awswrangler as wr

# create a Glue job and define the data source and target
def glue_job():
    s3_paths = ["s3:///.csv"]
    catalogid = boto3.client("sts").get_caller_identity()["Account"]
    database = ""
    table_name = ""
    connect_options = {
        "dbtable": table_name,
        "database": database,
        "instance": "",
        "port": ,
        "user": "",
        "password": "",
        "ssl": "require",
    }
    redshift_options = {
        "database": "",
        "host": "",
        "port": ,
        "user": "",
        "password": "",
    }

    # read data from RDS to GlueDynamicFrame
    dyf_rds = wr.rds.read_sql_table(
        table=connect_options["dbtable"],
        database=connect_options["database"],
        instance=connect_options["instance"],
        port=connect_options["port"],
        secret_id="",
    )

    # prepare data for write to Redshift
    dyf_redshift = wr.sanitize_dataframe(
        dyf_rds.toDF(), remove_newline=True, remove_return=True
    )
    dyf_redshift = wr.cast_dataframe(
        dyf=dyf_redshift,
        column_type_mapping={
            "timestamp_column_name": "timestamp",  # replace with your timestamp column name
        },
    )

    # write data to Redshift using Glue
    wr.redshift.load(
        dataframe=dyf_redshift,
        table="",
        schema="",
        iam_role="",
        redshift_options=redshift_options,
        num_files=1,
        mode="overwrite

相关内容

热门资讯

第二分钟辅助!wepoker怎... 第二分钟辅助!wepoker怎么开辅助,wpk作弊是真的吗,指引教程(有挂工具)1、这是跨平台的we...
十分钟辅助!wepoker辅助... 十分钟辅助!wepoker辅助器软件下载,wepoker透视版下载,秘籍教程(发现有挂)1、打开软件...
第九分钟辅助!wepoker游... 第九分钟辅助!wepoker游戏安装教程,aapoker脚本,手筋教程(真的有挂)1、进入游戏-大厅...
第六分钟辅助!wpk透视是真的... 第六分钟辅助!wpk透视是真的假的,xpoker怎么作弊,阶段教程(有挂分析)1、进入游戏-大厅左侧...
5分钟辅助!大菠萝辅助器,im... 5分钟辅助!大菠萝辅助器,impoker辅助,操作教程(有挂透明挂)1、上手简单,内置详细流程视频教...
2分钟辅助!aapoker能控... 您好,aapoker能控制牌吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302...
第1分钟辅助!WePOker有... 第1分钟辅助!WePOker有没有透视方法,aapoker怎么选牌,指引教程(有挂解密)1、WePO...
第九分钟辅助!wepoker透... 第九分钟辅助!wepoker透视脚本网页,如何下载wepoker安装包,技法教程(有挂方法)一、如何...
第八分钟辅助!wepoker安... 第八分钟辅助!wepoker安装教程,pokernow辅助控制,总结教程(有挂方略)在进入poker...
第八分钟辅助!德州机器人代打脚... 第八分钟辅助!德州机器人代打脚本,xpoker辅助助手,总结教程(有挂方略)德州机器人代打脚本透视方...