Re: [GENERAL] Load a csv to remote postgresql database

Поиск
Список
Период
Сортировка
От John R Pierce
Тема Re: [GENERAL] Load a csv to remote postgresql database
Дата
Msg-id c942bbfc-d316-df9e-c974-efb79def2a56@hogranch.com
обсуждение исходный текст
Ответ на [GENERAL] Load a csv to remote postgresql database  (priyanka raghav <priyankarag@gmail.com>)
Список pgsql-general
On 3/1/2017 10:01 PM, priyanka raghav wrote:
> I am trying to load a csv file of approx 500mb to remote postgres
> database. Earlier when the app server and db server were co-located,
> COPY command was working fine but ever since the db server is moved to
> a different box, the command is failing. I understand that COPY
> command searches the file on database server which it is not able to
> find and hence is throwing an error. I cannot use /COPY as it is a
> psql command. What options do I have to go about this. I need an
> urgent answer to this. Thanks in advance.

I recommend trying pgloader ...   http://pgloader.io/

but if you have to do it inside a program, without shelling out to
another program, then you'll have to figure out how to use the streaming
interface in your chose database API, along with  COPY tablename FROM
STDIN [WITH options...];    (note that does not actually mean its
reading from STDIN)    this what psql uses for \COPY, you then read the
local CSV file and send it to the appropriate streaming interface, for
instance if you're using libpq, you'd use...

https://www.postgresql.org/docs/current/static/libpq-copy.html#LIBPQ-COPY-SEND



--
john r pierce, recycling bits in santa cruz



В списке pgsql-general по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: [GENERAL] Load a csv to remote postgresql database
Следующее
От: Johann Spies
Дата:
Сообщение: [GENERAL] column "waiting" does not exist