Combining \i and \copy in psql - Mailing list pgsql-general

From Rhys A.D. Stewart
Subject Combining \i and \copy in psql
Date
Msg-id CACg0vTk2hJ8NXxVB2e13yMyeSO940d-1K22QV6zXAH5R89fG1Q@mail.gmail.com
Whole thread Raw
Responses Re: Combining \i and \copy in psql  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
Greetings,

I have a query in a .sql file and I'd like to use \i to execute it and
\copy to save it to a csv file. Is there any way to combine the two?

Something along the lines of:

\copy \i myquery.sql to 'output.csv'

Rhys
Peace & Love|Live Long & Prosper


pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Control PhoneNumber Via SQL
Next
From: "David G. Johnston"
Date:
Subject: Re: Combining \i and \copy in psql