Re: Exporting data from PostgreSQL - Mailing list pgsql-novice

From paul butler
Subject Re: Exporting data from PostgreSQL
Date
Msg-id 3EE98DA0.10462.7D9B17@localhost
Whole thread Raw
In response to Exporting data from PostgreSQL  (Michael Glaesemann <grzm@myrealbox.com>)
Responses Re: Exporting data from PostgreSQL
List pgsql-novice
Date sent:          Fri, 13 Jun 2003 15:20:59 +0900
Subject:            [NOVICE] Exporting data from PostgreSQL
From:               Michael Glaesemann <grzm@myrealbox.com>
To:                 pgsql-novice@postgresql.org
Try This,

Go into psql

mfx=# \pset fieldsep '\t'       // sets field delimiter to tab
Field separator is '    '.
mfx=# select * from actor;     // make your query
mfx=# \o d:\A\tester.txt       // set file to output results
mfx=# select * from actor;    // execute query

open up resulting test file in excel, and then do with it what you will.
Line breaks in long test fields are broken up over rows, but neatly.

There is also a php class (with varying licenses) to create excel sheets

http://www.web-aware.com/

Remember a few problems with text fields, but it did the job well enough

Hope this helps

Paul Butler

> Hello!
>
> I've been enjoying getting to know PostgreSQL and am happy that my
> queries seem to be working well. I've also been getting along in PHP
> and have been able to impress my boss (always a good thing!) with an
> easy way for her to manage some of her data using just a browser.
>
> Browsers are great, but sometimes you need hard copy, and often
> something other than printing the browser window. So I'd like to be
> able to get query results out of PostgreSQL somehow, hopefully in a
> tab-delimited file.
>
> I'm sure this is something pretty easy and I just haven't hit upon it.
> I've googled and come across EMS' PostgreSQL Export. Sounds like a
> great product, but I'm on a Mac, am not sure what's involved with using
> the Linux version on OS X and am not too keen on trying, and I don't
> think I need something so fancy. This is probably a pretty common task,
> so there must be a way to do it, I'd think
>
> Things I've thought of:
> COPY: Only works with tables, not views (from what I've read). Seems
> like a bit of a hassle to create a short-lived table to select into
> just to get some data out, but maybe that's what I should do.
> PHP (or other language): Make a script that'll do this for me. Can be
> used with query results.
>
> I'm probably missing something. I'd love to hear any ideas, including
> finding out if I'm just too lazy to use the two I've already thought
> of! :)
>
> Thanks any advice!
>
> Michael Glaesemann
> grzm myrealbox com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)



pgsql-novice by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: Multibyte support and accented characters
Next
From: "Marcus Andree S. Magalhaes"
Date:
Subject: number of rows