dbcli / pgcli

Postgres CLI with autocompletion and syntax highlighting
http://pgcli.com
BSD 3-Clause "New" or "Revised" License
12.17k stars 556 forks source link

\set would be very nice for variables #1269

Open hoopes opened 3 years ago

hoopes commented 3 years ago

Description

I have some psql scripts that i can invoke with a psql variable.

$ cat myscript.sql
select * from images where id = :'imgid';

$ psql
> \set imgid 123
> \i myscript.sql
...query result...

This doesn't appear supported on pgcli, unless I've missed it somehow. Is there any chance for this to be supported, or another way I could do it?

My real use-case is that the sql script has many queries, all of which are printed out. If the named queries system could execute more than one query at a time, it would be ideal, since that has an arguments system.

Your environment

Thanks so much, this is an awesome project!

xpe commented 3 years ago

I would also appreciate variable support.

BTW, the documentation page lives at: https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-VARIABLES