Problem with COPY FROM with PHP in postgresql
I have some big .csv files and I am trying to put it into database. I am using this c开发者_运维问答onstruction:
COPY table_name(column1, column2, column..., columnN) FROM stdin;
column1 column2 column... column N
column1 column2 column... column N
column1 column2 column... column N
column1 column2 column... column N
\.
But after use \i function in CLI I got that:
ERROR: end-of-copy marker corrupt
This is not a problem with end marker, but with encoding. If I open this file in VIM and will save it again, everything is OK, but without this operations I got this error all the time. What can I do in PHP (with PHP I create those files) to fix that? If this is for sure problem with encoding?
Is there also a newline after the \.
? Check the example in the PHP-manual for pg_put_line() as well and take notice of the \n
at the end.
There is a easy solution for this, you only need to press "Enter
" after "\.
" and then save your file and try again, it will resolve your issue.
精彩评论