pgcli silently fails if there's an error
See original GitHub issueDescription
I’m trying to run an INSERT
command that fails, but pgcli
doesn’t show any errors; example:
I create the following table:
create table my_table(col1 varchar(10) not null, col2 varchar(10))
Then, I try to do an invalid insertion:
insert into my_table(col2) values('should fail')
But pgcli
doesn’t show any errors and only shows:
my_db> insert into my_table(col2) values('should fail');
Time: 0.004s
Which gives the impression that the insertion worked and we’re good to go.
Whereas trying something similar with psql
would give these errors:
my_db=# insert into my_table(col2) values('should fail');
ERROR: value too long for type character varying(10)
my_db=# insert into my_table(col2) values('shouldfail');
ERROR: null value in column "col1" violates not-null constraint
DETAIL: Failing row contains (null, shouldfail).
Your environment
- Please provide your OS and version information. Manjaro Linux
- Please provide your CLI version. Version: 3.1.0
- What is the output of
pip freeze
command. not sure if this is helpful, but let me know and I can provide it
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
psql command is failing silently - Stack Overflow
If you want to use a “here document” with psql , do this: psql "$pg_cp_prod_conn_str" <<EOF ALTER TABLE cp_user_emails ADD CONSTRAINT ...
Read more >Install - pgcli
Check if pip is installed on the system. $ which pip. If the above command returns an error, then you do not have...
Read more >Insert statement fails silently when a FK constaint can't be ...
My bet is that: SELECT id FROM entity WHERE properties->>'member_id' = '92385'. returns NO ROWS (NO ERROR) and INSERT command is never ...
Read more >Documentation: 15: 43.9. Errors and Messages - PostgreSQL
Use the RAISE statement to report messages and raise errors. ... After level if any, you can specify a format string (which must...
Read more >pip install psql
If it is installed then you can do: $ pip install pgcli. ... OS, and Python version used there are several possible errors...
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
Very nice @lelit , thank you so much. Summary of what I did (in case people see this in the future):
--pgcli-fix
and--csv
frompspg
optionstable_format = psql
(the default)After this, the table borders didn’t look at pretty as before, so I added
--force-uniborder
topspg
, and now I see the errors, super nice 💯Closing this issue since, as far as I’m concerned, my issue is solved (thank you @lelit again)
And thank you @amjith for following up with this
Can you enable debug logging in pgcli? You can do that via the config file in ~/.config/pgcli/config change the log_lever to
DEBUG
.Run the above commands and check the log file: ~/.config/pgcli/log. I see the following in my pgcli log file: