COPY command with PHP

From: Robert Fitzpatrick <robert(at)webtent(dot)com>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: COPY command with PHP
Date: 2004-10-23 15:49:59
Message-ID: 1098546599.11072.15.camel@columbus.webtent.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a PHP script that was having problems using the COPY command with
files around 1500 lines in size. The script will build the copy data
from incoming CSV file into a temp file, then start a COPY command and
loop through the copy data using pg_put_line to insert and then
pg_end_copy after posting the last line as '\.'. Worked well under that
1500 line area. What I found was if I issue a pg_connection_busy($dbh)
before the pg_put_line(...) in the while statement processing the lines
of the temp file handle, it works. Don't ask me why, that is what I'd
like to know. If I report back if busy is true, I get nothing. Maybe it
is just giving a millisecond to breathe or something while checking to
see if the connection is busy? One thing though, don't know if it had
anything to do with it, the script is on an old box with an AMD 300
processor with maybe 256MB memory while the database is on an up to date
dual Pentium 4 processor with 1GB mem.

Of course, if I took the copy data file it is trying to COPY into
PostgreSQL and psql to bring it in on the server directly, no issues.
Not that it doesn't work with the busy check, just curious as to what is
causing the need for it since I spent many hours to finally find the
answer. No one on the PHP list seemed to know.

--
Robert

Browse pgsql-general by date

  From Date Subject
Next Message Oliver Elphick 2004-10-23 15:59:26 Re: Slony-I 1.0.4 Released
Previous Message Leen Besselink 2004-10-23 15:46:51 Re: OID's