Thread: piping output to file
Is there an easy way to pipe a select statement's output to a file? -- [ Russ Schneider (a.k.a. Sugapablo) ] [ http://www.sugapablo.com <--music ] [ http://www.sugapablo.net <--personal ] [ sugapablo@12jabber.com <--jabber IM ]
On Sun, Feb 08, 2004 at 12:28:21PM -0500, Russ Schneider wrote: > Is there an easy way to pipe a select statement's output to a file? In psql, type \? and look at what \o and \g do. They both do it but slightly differently. -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > (... have gone from d-i being barely usable even by its developers > anywhere, to being about 20% done. Sweet. And the last 80% usually takes > 20% of the time, too, right?) -- Anthony Towns, debian-devel-announce
Attachment
That would depend on the client you're using. psql can do it either directly (using \o) or by piping its output: psql -c "select * from mytable;" mydb > out.txt If you're using a programming library, I think you're on your own. Adam Ruth On Feb 8, 2004, at 10:28 AM, Russ Schneider wrote: > Is there an easy way to pipe a select statement's output to a file? > > -- > [ Russ Schneider (a.k.a. Sugapablo) ] > [ http://www.sugapablo.com <--music ] > [ http://www.sugapablo.net <--personal ] > [ sugapablo@12jabber.com <--jabber IM ] > > ---------------------------(end of > broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org >
On Sun, 8 Feb 2004, Russ Schneider wrote: > Is there an easy way to pipe a select statement's output to a file? In psql you can use \o [filename] to direct query output to a file.
also, $ psql -c "select whatever_you_want from table_name" > outfile reid > -----Original Message----- > From: scott.marlowe [mailto:scott.marlowe@ihs.com] > Sent: Monday, February 09, 2004 12:17 PM > To: Russ Schneider > Cc: pgsql-general > Subject: Re: [GENERAL] piping output to file > > > On Sun, 8 Feb 2004, Russ Schneider wrote: > > > Is there an easy way to pipe a select statement's output to a file? > > In psql you can use \o [filename] to direct query output to a file. > > > ---------------------------(end of > broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to > majordomo@postgresql.org) >