RE: COPY with PostgreSQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



What are the line endings of the file?  Maybe php is getting confused.
How many KB is the file on disk when it's the ~1500 line version?
There's length of each line (which you want under 1KB, probably not a
problem unless you have BLOBS or equivalent) - and then there's how PHP
determines what a line actually is.

Both of these could be causing a syntax error if PHP isn't reading the
entire chunk in and feeding it whole to postgresql.

... this may be helpful - from description of fgets()
If you are having problems with PHP not recognizing the line endings
when reading files either on or created by a Macintosh computer, you
might want to enable the auto_detect_line_endings run-time configuration
option.

- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.


-----Original Message-----
From: Robert Fitzpatrick [mailto:robert@xxxxxxxxxxx] 
Sent: Friday, October 22, 2004 1:18 AM
To: PHP Databases
Subject:  COPY with PostgreSQL


I am using COPY for PostgreSQL and having problems now that the incoming
file contains more than approx 1500 lines. Is this an issue anyone is
aware of? Lot's of files over 1000 lines have worked fine, but after
getting a file over 1800 I began having problems. I have broke the file
down to a approx. 1500 line that works sometimes and not others. Here is
a snippet of what I'm trying to do:

  $result = pg_exec($dbh, "COPY tblxrf FROM stdin USING DELIMITERS
','");
  fseek($temp_fh,0); // go to beginning of temp file
  while (($csv_line = fgets($temp_fh,1024))) {
   pg_put_line($dbh, $csv_line);
  }
  $stat = pg_put_line($dbh, "\\.\n"); // notify db finished or report
error
  if (!$stat) { echo "ERROR: An error has occurred while putting last
line of copy data<br>\n"; exit; }
  $stat = pg_end_copy($dbh); // post (sync data) or report error

The process just hangs with the large number of lines, I have to kill
the COPY process for postgresql on the server before trying again.

--
Robert

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux