Forum OpenACS Q&A: Re: Running the psql COPY command from db_dml

Collapse
Posted by Nis Jørgensen on
Since the file is probably local to the webserver, and thus not necessarily local to the database server, \copy is probably more apropriate than the sql copy command.

Anyway, it seems to me like this is about importing into a temporary table, and we will need to run inserts from that table afterwards anyway. Of course this might be doable using one statement for all rows, removing the overhead of 20000 inserts+constraint validations - but if these imports are going to end up in the users table (just a guess), we probably will have to handle them separately at some point anyway.

/Nis

hmmm... Several things out of this:

a) Since till now in my development environment the database and the webserver are in the same machine, I never met problems with COPY (except the superuser limitation). But, if I continue using it (COPY), do I gather right from your comments that it will not work on my production environment (where db and web are on different machines)?
And this would be solved (as the superuser limitation) with \copy ?

b) Yes, I will handle them seperatelly at some point. But the way I am doing it with this new "import shell", the import itself is one quick step. Then each record I handle, gets "tagged" as "done" or with an error message. When I handle the individual records, I dont' care if the process stops in the middle for any reason (which was happening with the imports till now because of a server down or whatever), because I always know which records have been processed and which not. Also, if for any reason I want to stop an import in the middle, I also can do it easily, and resume etc.