pgcli
pgcli copied to clipboard
\set would be very nice for variables
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
- [x] Please provide your OS and version information.
- Ubuntu 20.04.2
- [x] Please provide your CLI version.
- 3.1.0
- [x] What is the output of
pip freezecommand.
$ pip freeze
cli-helpers==2.1.0
click==7.1.2
configobj==5.0.6
pendulum==2.1.2
pgcli==3.1.0
pgspecial==1.12.1
prompt-toolkit==3.0.16
psycopg2==2.8.6
Pygments==2.8.0
python-dateutil==2.8.1
pytzdata==2020.1
setproctitle==1.2.2
six==1.15.0
sqlparse==0.4.1
tabulate==0.8.7
terminaltables==3.1.0
wcwidth==0.2.5
Thanks so much, this is an awesome project!
I would also appreciate variable support.
BTW, the documentation page lives at: https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-VARIABLES