1
我在嘗試複製到AWS Redshift時遇到此問題。 這是我試圖運行代碼:psycopg2.ProgrammingError:嘗試copy_from紅移時出現「stdin」錯誤或出現「stdin」錯誤時出現語法錯誤
with open('path/to/files, 'rb') as fo:
cursor.copy_from(fo, 'schema.table', sep=',')
cursor.commit()
我遇到的錯誤:
psycopg2.ProgrammingError: syntax error at or near "stdin"
LINE 1: ...Y schema.table FROM stdin WITH...
我正在運行的Python 3.5 psycopg2。 希望你們能幫助! Thx提前!
謝謝你的幫助! – Larry
@CraigRinger我理解你的觀點,看看如何從命令行或數據庫工具(DBeaver等)使用COPY,但是如何從python腳本中複製表格。你會建議什麼模塊和語法? –
您可能不得不使用多插入,或者從那裏生成要上傳到s3和「COPY」的數據。 *聳肩*。我不使用Redshift。也許你應該發佈一個新的問題並且鏈接回這個問題? –