【问题标题】:statement too large while pushing data into redshift database from python从python将数据推送到redshift数据库时语句太大
【发布时间】:2018-11-26 13:25:15
【问题描述】:

我在 redshift 表中推送 pandas 数据框并出现以下错误

cur.execute("INSERT INTO sir_main VALUES " + str(args_str))
psycopg2.ProgrammingError: Statement is too large. Statement Size: 58034743 
bytes. Maximum Allowed: 16777216 bytes`

它会停止执行。推入数据库时​​有什么方法可以配置限制吗?

【问题讨论】:

  • 不,如果这是您的常规流程,您应该考虑更改方法,以便先将数据加载到 s3,然后使用 aws copy 命令。

标签: python amazon-redshift


【解决方案1】:

如果您要加载的行数超过几百行,则应将数据帧作为平面文件保存到 S3,然后使用 COPY 将其加载到 Redshift。 https://docs.aws.amazon.com/redshift/latest/dg/r_COPY.html

【讨论】:

    猜你喜欢
    • 2016-09-22
    • 1970-01-01
    • 1970-01-01
    • 2021-08-28
    • 2014-04-19
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    • 2015-10-23
    相关资源
    最近更新 更多