SQL errors are discarded when using the pspg pager
See original GitHub issueDescription
I use the following settings in my pgclirc
file:
pager = pspg --csv --rr=2 --quit-if-one-screen --ignore-case --csv-header on -s 4 -X
table_format = csv
and I’m quite happy, except for one notable defect: when I execute a query containing an error, pgcli does not properly handle the case and still emit the output coming from PG thru the pager, that simply discards it not being a CSV
stream.
For example, not using the pager I get:
$ pgcli -h localhost -u user -d test
Server: PostgreSQL 11.8 (Debian 11.8-1.pgdg90+1)
Version: 3.0.0
Chat: https://gitter.im/dbcli/pgcli
Home: http://pgcli.com
user@localhost:test> select foo;
column "foo" does not exist
LINE 1: select foo
^
Time: 0.001s
while going thru pspg
this is what I get:
$ pgcli -h localhost -u user -d test --pgclirc my.pgclirc
Server: PostgreSQL 11.8 (Debian 11.8-1.pgdg90+1)
Version: 3.0.0
Chat: https://gitter.im/dbcli/pgcli
Home: http://pgcli.com
user@localhost:test> select foo;
Time: 0.002s
Maybe the _evaluate_command() function should return that success
flag to the caller and the latter emit the output without the pager?
Environment
$ pip freeze
cli-helpers==2.1.0
click==7.1.2
configobj==5.0.6
pendulum==2.1.2
-e git+https://github.com/dbcli/pgcli.git@8f7e31450835bca5d9a8bb4de252efba6f4b7b10#egg=pgcli
pgspecial==1.11.10
prompt-toolkit==3.0.5
psycopg2==2.8.4
pudb==2019.2
Pygments==2.6.1
python-dateutil==2.8.1
pytzdata==2020.1
setproctitle==1.1.10
six==1.15.0
sqlparse==0.3.1
tabulate==0.8.7
terminaltables==3.1.0
urwid==2.1.1
wcwidth==0.2.5
$ pspg --version
pspg-2.6.6
with readline (version: 0x0603)
with integrated menu
ncurses version: 6.1, patch: 20190112
ncurses with wide char support
ncurses widechar num: 1
wchar_t width: 4, max: 2147483647
with postgres client integration
The same happens with latest released version of pspg
, 3.1.2.
Issue Analytics
- State:
- Created 3 years ago
- Comments:20 (14 by maintainers)
Top Results From Across the Web
Developers - SQL errors are discarded when using the pspg pager -
I use the following settings in my pgclirc file: pager = pspg --csv --rr=2 --quit-if-one-screen --ignore-case --csv-header on -s 4 -X table_format =...
Read more >How to use pspg for mycli pager - mysql - Stack Overflow
This answer in github works great. In my .my.cnf I added this [client_visidata] pager = pspg -X --quit-if-one-screen. Then use the ...
Read more >okbob/pspg - Postgres Pager - GitHub
Works well with pgcli too. Can be used as CSV or TSV viewer too. It supports searching, selecting rows, columns, or block and...
Read more >Documentation: 15: psql - PostgreSQL
Run in single-step mode. That means the user is prompted before each command is sent to the server, with the option to cancel...
Read more >Tips and tricks - Sourcegraph Handbook
Playbooks for deployments On this page • Playbooks for deployments Playbooks ... a Cloud SQL instance to a previous revision you can use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
so 12. 6. 2021 v 11:56 odesílatel Lele Gaifax @.***> napsal:
I modified pspg readme
Thank you for check
Pavel
Yes, I confirm that what @okbob suggested fixes this issue!
To be clear, now my
pgclirc
containsand everything seems working as expected 🎉.
As a side note for @okbob: after looking up the meaning for the
--pgcli-fix
option you suggest in thepgcli
section, it seems redundant without--csv
.Thanks a lot!