psycopg2.ProgrammingError: syntax error at or near “stdin” error when trying to copy_from redshift

吃可爱长大的小学妹 提交于 2019-12-23 16:34:41

问题


I am having this problem when I am trying to copy to AWS redshift. This is the code I am trying to run:

with open('path/to/files, 'rb') as fo:
    cursor.copy_from(fo, 'schema.table', sep=',')
    cursor.commit()

And I encountered the error:

psycopg2.ProgrammingError: syntax error at or near "stdin" 
LINE 1: ...Y schema.table FROM stdin WITH...

I am running python 3.5 with psycopg2. Hope that you guys can help! Thx in advance!


回答1:


AWS Redshift is not PostgreSQL, though it supports a subset of PostgreSQL syntax and functionality.

It does not have COPY ... FROM STDIN.

See the manual for how to use COPY on Redshift.




回答2:


check this solution Python psycopg2 insert NULL in some rows in postgresql table

for insert multiple rows or python dataframe in Redshift



来源:https://stackoverflow.com/questions/40904489/psycopg2-programmingerror-syntax-error-at-or-near-stdin-error-when-trying-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!