Обсуждение: query to file

Поиск
Список
Период
Сортировка

query to file

От
Judith Altamirano Figueroa
Дата:
Excuse me, how can I send a query to a file?, for example the result of
this query:

select id_articulo, articulo, color_code from articulos;




Re: query to file

От
Michael Glaesemann
Дата:
On Oct 19, 2005, at 8:03 , Judith Altamirano Figueroa wrote:

> Excuse me, how can I send a query to a file?, for example the  
> result of
> this query:
>
> select id_articulo, articulo, color_code from articulos;

You don't mention what client you're using. In psql, you can use

\o path/to/file.txt

For more psql goodness, take a look at:

http://www.postgresql.org/docs/8.0/interactive/app-psql.html

Hope this helps!

Michael Glaesemann
grzm myrealbox com





Re: query to file

От
Michael Fuhr
Дата:
On Tue, Oct 18, 2005 at 06:03:59PM -0500, Judith Altamirano Figueroa wrote:
> Excuse me, how can I send a query to a file?, for example the result of
> this query:
> 
> select id_articulo, articulo, color_code from articulos;

If you have a shell on a platform that supports input/output
redirection then you could redirect psql's output:

psql -c 'select ...' > filename

From within psql you could use \g or \o; see the documentation for
more information.

http://www.postgresql.org/docs/8.0/interactive/app-psql.html

If you're using some other client then consult its documentation.

-- 
Michael Fuhr


Re: query to file

От
"Eugene E."
Дата:
Judith Altamirano Figueroa wrote:
> Excuse me, how can I send a query to a file?, for example the result of
> this query:
> 
> select id_articulo, articulo, color_code from articulos;

if you mean psql

\o filename

and try to read output of a command \?