X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 20070D785A for ; Thu, 25 Aug 2005 20:55:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40803-03 for ; Thu, 25 Aug 2005 23:55:54 +0000 (GMT) Received: from polaris.pinpointresearch.com (66-7-238-130.cust.telepacific.net [66.7.238.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6EC42D784E for ; Thu, 25 Aug 2005 20:55:52 -0300 (ADT) Received: from betelgeuse.pinpointresearch.com (betelgeuse.pinpointresearch.com [192.168.1.179]) by polaris.pinpointresearch.com (Postfix) with ESMTP id 07A7F1044C; Thu, 25 Aug 2005 16:55:56 -0700 (PDT) From: Steve Crawford Organization: Pinpoint Research To: David Durham , pgsql-admin@postgresql.org Subject: Re: dumping query results to a csv Date: Thu, 25 Aug 2005 16:55:55 -0700 User-Agent: KMail/1.5.1 References: <430E4536.3030203@vailsys.com> In-Reply-To: <430E4536.3030203@vailsys.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200508251655.55679.scrawford@pinpointresearch.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.066 required=5 tests=[AWL=0.016, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200508/333 X-Sequence-Number: 18652 On Thursday 25 August 2005 3:24 pm, David Durham wrote: > This is kind of a pg-admin newbie question, so apologies in > advance. > > Anyway, I'd like to issue a command that dumps the results of a > query to a txt file in comma delimited format. Does PostgreSQL > ship with something to do this? I searched the web, but found what > appeared to be non-free solutions. Use heredoc notation to set the format to unaligned, set your field separator (and, if necessary, record separator) to whatever you want, turn off the footer, and run the output to a file: psql --quiet databasename < --quiet --no-align --field-separator ',' --pset footer --output youroutputfile.csv --command