Combining \i and \copy in psql

From: "Rhys A(dot)D(dot) Stewart" <rhys(dot)stewart(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Combining \i and \copy in psql
Date: 2018-05-15 15:30:16
Message-ID: CACg0vTk2hJ8NXxVB2e13yMyeSO940d-1K22QV6zXAH5R89fG1Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2018-05-15 15:35:06 Re: Combining \i and \copy in psql
Previous Message Alvaro Herrera 2018-05-15 15:23:14 Re: Control PhoneNumber Via SQL