Hi.
I was tinkering around with pg_put_line and pg_end_copy and rather than
inserting data from a variable as per the example, I was wondering if it was
posible to insert the data from a delimited file via these two functions.
I produced a dump from postgres and tried inserting the data raw
$text = file("test.sql");
$db = pg_connect("host=localhost dbname=testing user=testing");
pg_exec($db, "COPY test FROM stdin");
foreach($text as $line) {
echo $line, "<BR>";
pg_put_line($db,$line);
flush();
}
pg_end_copy($db);
but this caused an error to occur. The example in the docs had the new lines
and tabs escaped so I tried that as well with addslashes()
$text = file("test.sql");
$db = pg_connect("host=localhost dbname=graeme user=graeme");
pg_exec($db, "COPY test FROM stdin");
foreach($text as $line) {
$line = addslashes($line);
$line = ereg_replace(9,"\\t",$line);
$line = ereg_replace(10,"\\n",$line);
echo $line, "<BR>";
pg_put_line($db,$line);
flush();
}
pg_end_copy($db);
and while the data was exactly the same format as the example, I managed to
get postgres stuck in COPY and had to manually kill the postgres COPY
process to recover.
Any one have any ideas?
Cheers,
Graeme
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]