psycopg2.ProgrammingError:尝试copy_from redshift时出现"stdin"错误或其附近的语法错误

Lar*_*rry 3 postgresql stdin psycopg2 python-3.x amazon-redshift

当我尝试复制到AWS redshift时遇到此问题.这是我试图运行的代码:

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

我遇到了错误:

psycopg2.ProgrammingError: syntax error at or near "stdin" 
LINE 1: ...Y schema.table FROM stdin WITH...
Run Code Online (Sandbox Code Playgroud)

我用psycopg2运行python 3.5.希望你们能帮忙!Thx提前!

Cra*_*ger 6

AWS Redshift不是PostgreSQL,但它支持PostgreSQL语法和功能的子集.

它没有COPY ... FROM STDIN.

有关如何在Redshift 上使用的信息,请参阅手册COPY.