Re: bulk insert using COPY and PHP code

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Babu R <babu_4blog(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: bulk insert using COPY and PHP code
Date: 2010-07-02 10:52:44
Message-ID: AANLkTimI0MjRa_q6xUzu2zRq2Rcud6ZPtTdmnDKk--A5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2010/7/2 Babu R <babu_4blog(at)yahoo(dot)com>
>
> Hello,
>
> Am exploring a way for bulk insert using \COPY with the CSV format data using PHP code. Is there any way to achieve this?
>
> Thanks,
> - Babu
>
hello

look on http://php.net/manual/en/function.pg-put-line.php

<?php
$conn = pg_pconnect("dbname=foo");
pg_query($conn, "create table bar (a int4, b char(16), d float8)");
pg_query($conn, "copy bar from stdin");
pg_put_line($conn, "3\thello world\t4.5\n");
pg_put_line($conn, "4\tgoodbye world\t7.11\n");
pg_put_line($conn, "\\.\n");
pg_end_copy($conn);
?>

Regards

Pavel Stehule

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Geoffrey 2010-07-02 11:36:59 pgpool-II (max_pool and num_init_children)
Previous Message Babu R 2010-07-02 10:46:37 bulk insert using COPY and PHP code