Re: How to mix psql commands and SQL commands on the shell command line?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Aleksey Tsalolikhin <atsaloli(dot)tech(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to mix psql commands and SQL commands on the shell command line?
Date: 2012-12-07 20:14:18
Message-ID: CAFj8pRAG8iGfY3esw0rZT73hhtCqA7cJdeurJNdtoB6k9gBS1g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

2012/12/7 Aleksey Tsalolikhin <atsaloli(dot)tech(at)gmail(dot)com>:
> How can I mix psql commands and SQL commands on the shell command line, please?
>
> $ psql
> psql (9.2.1)
> Type "help" for help.
>
> ddcKeyGen=> \timing \\ select count(*) from auth_users;
> Timing is on.
> count
> -------
> 276
> (1 row)
>
> Time: 1.730 ms
>
> $ psql -c "\timing \\ select count(*) from auth_users;"
> Timing is on.
> $
>

you can try pipe

pavel(at)nemesis ~ $ echo $'\\timing\nselect 10;' | psql postgres
Timing is on.
?column?
──────────
10
(1 row)

Time: 0.478 ms

Regards

Pavel Stehule

> It seems like psql discards everything after the first psql
> argument... Is there another way to mix psql and SQL commands on the
> shell command line?
>
> Best,
> Aleksey
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sergey Konoplev 2012-12-07 21:36:00 Re: unlooged tables
Previous Message Adrian Klaver 2012-12-07 20:09:01 Re: How to mix psql commands and SQL commands on the shell command line?