Re: Exporting data from PostgreSQL

From: "paul butler" <paul(at)entropia(dot)co(dot)uk>
To: Michael Glaesemann <grzm(at)myrealbox(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Exporting data from PostgreSQL
Date: 2003-06-13 07:38:56
Message-ID: 3EE98DA0.10462.7D9B17@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Date sent: Fri, 13 Jun 2003 15:20:59 +0900
Subject: [NOVICE] Exporting data from PostgreSQL
From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: pgsql-novice(at)postgresql(dot)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(at)postgresql(dot)org)

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Marcus Andree S. Magalhaes 2003-06-13 09:04:56 number of rows
Previous Message Michael Glaesemann 2003-06-13 07:06:17 Re: Multibyte support and accented characters