Re: fine tuned database dump/reload? - Mailing list pgsql-general

From Richard Huxton
Subject Re: fine tuned database dump/reload?
Date
Msg-id 434C09A1.3070103@archonet.com
Whole thread Raw
In response to Re: fine tuned database dump/reload?  (Dan Armbrust <daniel.armbrust.list@gmail.com>)
List pgsql-general
Dan Armbrust wrote:
>
> Is there a better way to do this?  Is there a flag I could specify for
> psql that would cause it to output INSERT or COPY statements as a result
> of a query - select * from foo where terminologyId=foo?  Then I could
> just have 15 select statements batched up in a file, and pipe the output
> into a new file.

It's easy enough to get psql to output tab-separated columns to a file
from its query (see the various backslash formatting commands and \o).
Spit out the 15 different files you want to /tmp, then use a script with
COPY ... FROM /tmp/file1 etc.

If you use COPY the files need to be readable by the backend process,
otherwise look into \copy in a psql script.

If it gets much more complicated, I knock up a short Perl script. Others
probably prefer Python or Ruby.
--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Tony Caduto
Date:
Subject: Re: Considering an upgrade...
Next
From: Scott Marlowe
Date:
Subject: Re: Considering an upgrade...