Re: Postgres Pg_connect PHP

From: Vyacheslav Kalinin <vka(at)mgcp(dot)com>
To: Tory M Blue <tmblue(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgres Pg_connect PHP
Date: 2009-06-09 18:41:36
Message-ID: 9b1af80e0906091141k78c0e780n59fe29ed608d4092@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jun 9, 2009 at 10:35 PM, Tory M Blue <tmblue(at)gmail(dot)com> wrote:

>
> Thanks guys, the problem with copy from or to is that it creates an
> array and thus puts a load of stuff in memory, it's possible the file
> will get huge and I can't take that memory hit.
>
> I'll look again and see if I missed something
>
> Thanks
> Tory
>

It's not hard to do some streaming with copy (untested):

$conn = pg_pconnect("dbname=foo");
$fd = fopen('file.dat', 'r');
while (!feof($fd)) {
pg_put_line($conn, fgets($fd));
}
fclose($fd);
pg_put_line($conn, "\\.\n");
pg_end_copy($conn);

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vyacheslav Kalinin 2009-06-09 18:43:25 Re: Postgres Pg_connect PHP
Previous Message Tory M Blue 2009-06-09 18:35:12 Re: Postgres Pg_connect PHP