【发布时间】:2021-07-28 04:15:06
【问题描述】:
我收到此错误
SyntaxError: Statement is too large. Statement Size: 19780406 bytes. Maximum Allowed: 16777216 bytes
我什至还删除了一些列以使插入成为可能,但它不起作用,不能删除更多的列。 我收到此代码的此错误
red_conn = create_engine(
f"postgresql:<credentials>)
from sqlalchemy import event
@event.listens_for(red_conn, "before_cursor_execute")
def receive_before_cursor_execute(
conn, cursor, statement, params, context, executemany
):
if executemany:
cursor.fast_executemany = True
df.to_sql('table1',red_conn,index=False,schema='schemaname',if_exists='append',\
method='multi',chunksize=5000)
使用 批量复制 或 复制命令 将此数据帧存储到 CSV 然后将其移动到 s3 并使用复制命令插入会导致 ANSI 错误和大量类型和数据不匹配。 我更喜欢将数据框直接加载到红移,无论是批量还是其他方式。 请帮助如何将数据从数据帧插入红移,而不会受到任何语句长度限制。 非常感谢!
【问题讨论】:
标签: python postgresql dataframe amazon-redshift amazon-redshift-spectrum