Command line export or copy utility?
Command line export or copy utility?
От:
Francisco Reyes <lists@stringsutils.com>
Дата:
Does anyone know of any export or copy utility that runs on FreeBSD? I basically need a program that will connect to one database, do a select and copy the result to a second database. Alternatively a tool which would export the data in a format suitable to be loaded by psql is just fine. Found some windows utilities that pretty much do what I need, but I need a utility that would run from a FreeBSD machine since the machines where the data will be getting moved are both FreeBSD and at a data center. I am about to write a program for this in python, but if anyone knows of a utility would be great. I will be doing queries like: select * from source table where I found pgexport http://gborg.postgresql.org/project/pgexport/projdisplay.php, but it did not support the where clause and an email to the author bounced which I guess means he may no longer support the program. If the program wasn't in perl I wouldn't mind fixing it up. :-)
Re: Command line export or copy utility?
От:
Scott Ribe <scott_ribe@killerbytes.com>
Дата:
Use psql; it provides all the command-line options you need. -- Scott Ribe scott_ribe@killerbytes.com http://www.killerbytes.com/ (303) 722-0567 voice
Re: Command line export or copy utility?
От:
Brent Wood <b.wood@niwa.co.nz>
Дата:
Francisco Reyes wrote: > Does anyone know of any export or copy utility that runs on FreeBSD? > I basically need a program that will connect to one database, do a > select and copy the result to a second database. There are a few ways, from memory (so I might have the odd syntax error): To replicate a table run pg_dump on one machine pointing at the host/db to export & pipe the output to psql -f with the host & name of the target db. pg_dump -h host0 -d db0 -t table ... | psql -h host1 -d db1 -f you can do similar data streams from one db to another with (if the target table exists): psql .... -c "copy table to STDOUT ..." | psql ... -c "copy table from STDOUT ..." to do this with the results of a query to subset the data will require the pre-building of the target table, but you can do: psql -h host0 -d db0 -F"|" -Atc "select.....;" | psql -h host1 -d db1 -c "copy table from STDIN with delimiters = '|';" Cheers, Brent Wood
Re: Command line export or copy utility?
От:
Reece Hart <reece@harts.net>
Дата:
On Tue, 2007-05-22 at 18:07 -0400, Francisco Reyes wrote: > Does anyone know of any export or copy utility that runs on FreeBSD? > I basically need a program that will connect to one database, do a > select and copy the result to a second database. Two options: 1) if you want a whole table or schema, a pipe works nicely: eg$ pg_dump -t
Re: Command line export or copy utility?
От:
Francisco Reyes <lists@stringsutils.com>
Дата:
Reece Hart writes: > On Tue, 2007-05-22 at 18:07 -0400, Francisco Reyes wrote: >> Does anyone know of any export or copy utility that runs on FreeBSD? >> I basically need a program that will connect to one database, do a >> select and copy the result to a second database. > > Two options: > 1) if you want a whole table or schema, a pipe works nicely: > eg$ pg_dump -t