Re: bulk insert using COPY and PHP code

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Babu R <babu_4blog(at)yahoo(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: bulk insert using COPY and PHP code
Date: 2010-07-02 19:33:30
Message-ID: AANLkTim8Ej_mrmu59CAWfHnPUmLOiYn6etVQwNTd5dBR@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jul 2, 2010 at 1:28 PM, Babu R <babu_4blog(at)yahoo(dot)com> wrote:
>
> Hi Pavel,
>
> Thanks.
>
> The situation is, I have the DB class which will return the connection object that is created using the PDO class. And am using that object to perform the db operations. ie: $DB->prepare("")
>
> Further I have the data in a CSV file which has to be inserted into the table.
>
> Here is the command that I have used to import that data:
>
> $DB->exec("\COPY table1 FROM data.csv WITH DELIMITERS ','");

As mentioned earlier just use copy, also look into using copy from
stdin and then just feeding the lines to pgsql through php instead of
having pgsql get it from a system file. This way the php script and
the db don't have to be on the same machine.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Geoffrey 2010-07-02 20:15:41 Re: pgpool-II (max_pool and num_init_children)
Previous Message Rikard Bosnjakovic 2010-07-02 18:43:48 New DB-design - help and documentation pointers appreciated