Skip site navigation (1) Skip section navigation (2)

RE: ...copy hack

From: Magnus Hagander <mha(at)sollentuna(dot)net>
To: "'Daniele Medri'" <madrid(at)linux(dot)it>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: RE: ...copy hack
Date: 2000-03-31 12:43:08
Message-ID: 215896B6B5E1CF11BC5600805FFEA8210304606A@sirius.edu.sollentuna.se (view raw or flat)
Thread:
Lists: pgsql-hackers
> so...
> from your aswer i post another question:
> I have data on a pg db..  i want a text-file with this format 
> for gnuplot...
> 
> 1 2
> 1 3
> 1 5
> 3 5
> 
> for 2d plotting and..
> 
> 1 2 3
> 3 4 6
> 3 6 8
> 3 5 7
> 
> for 3d plottting.
> 
> I know that with a view i can obtain a right data visualizzation...
> I know that with copy i can put "data" from table to file...
> I would use "copy" to put view data into a file... a raw 
> copy.. but you've
> your own opinion.. Ok.
> How do you do to put data into my text file without outer 
> language or bash
> scripting?
> ..i mean using only pg tools?

psql yourdatabase -F" " -A -t -c "SELECT field1,field2 FROM yourview" -o
ouputfile

Should do what you want, I think.  (Assuming that it spaces between the
fields, and not tabs - you will need to change what's after -F if it's
different)

-F sets field separator.
-A sets "unaligned mode"
-t turns off header and footer
-c sets query to run
-o sets file to write output to (if not set, you get it on stdout)


There is a *lot* of functionality in the psql frontend :-)

//Magnus

pgsql-hackers by date

Next:From: HorĂ¡k DanielDate: 2000-03-31 13:51:14
Subject: RE: Call for platform reports
Previous:From: Daniele MedriDate: 2000-03-31 11:46:57
Subject: Re: ...copy hack

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group