Thread: Creating Text Files from Tables

Creating Text Files from Tables

From
"Warren Murray"
Date:
This maybe be on a more complex side, but I'm a novice to say the least, how
can I  export a text delimited file from Postgresql.  The file will be
transferred into a specific directory for use with another system.  text
file row sample: 396,"bigshoes.blue.7"

My last question is how can I create a series of fixed-width text files from
tables and/or queries in a Postgresql database?

Warren

Re: Creating Text Files from Tables

From
"A. Kretschmer"
Date:
am  10.02.2006, um  7:06:52 -0600 mailte Warren Murray folgendes:
> This maybe be on a more complex side, but I'm a novice to say the least, how
> can I  export a text delimited file from Postgresql.  The file will be
> transferred into a specific directory for use with another system.  text
> file row sample: 396,"bigshoes.blue.7"
>
> My last question is how can I create a series of fixed-width text files from
> tables and/or queries in a Postgresql database?

You can use untrusted languages such as plperlu for this.


HTH, Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47215,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===

Re: Creating Text Files from Tables

From
John DeSoi
Date:
On Feb 10, 2006, at 8:06 AM, Warren Murray wrote:

> This maybe be on a more complex side, but I'm a novice to say the
> least, how
> can I  export a text delimited file from Postgresql.  The file will be
> transferred into a specific directory for use with another system.
> text
> file row sample: 396,"bigshoes.blue.7"

The COPY command can produce CSV files (as well as files with other
delimiters):

http://www.postgresql.org/docs/8.1/interactive/sql-copy.html



>
> My last question is how can I create a series of fixed-width text
> files from
> tables and/or queries in a Postgresql database?


You could write some pl/pgsql functions to write the data to a temp
table and then COPY it.




John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


Re: Creating Text Files from Tables

From
Michael Fuhr
Date:
On Fri, Feb 10, 2006 at 03:17:31PM +0100, A. Kretschmer wrote:
> am  10.02.2006, um  7:06:52 -0600 mailte Warren Murray folgendes:
> > This maybe be on a more complex side, but I'm a novice to say the least, how
> > can I  export a text delimited file from Postgresql.  The file will be
> > transferred into a specific directory for use with another system.  text
> > file row sample: 396,"bigshoes.blue.7"
> >
> > My last question is how can I create a series of fixed-width text files from
> > tables and/or queries in a Postgresql database?
>
> You can use untrusted languages such as plperlu for this.

Depending on your formatting requirements, COPY or psql's \copy or
\o commands might work, or even running a psql one-liner from the
command line and redirecting the output.  See the psql documentation
for formatting options.

--
Michael Fuhr