Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 690
Larry Avatar asked Feb 06 '23 14:02

Larry


1 Answers

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.

like image 131
Craig Ringer Avatar answered Mar 19 '23 17:03

Craig Ringer