-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --ping
as a CLI option
#1471
Conversation
This builds in the functionality asked for in dbcli#1470; it allows pgcli to replace `pg_isready` from the postgresql command line toolchain
@offbyone This looks nice! I'd add an integration test scenario for this as well, see pgcli/tests/features/basic_commands.feature Lines 50 to 52 in 46fe654
|
pgcli.echo doesn't seem to actually _echo_ anything
I added two feature tests, but one of them is failing and I don't quite know why; the exit code 0 is coming back with exit code 120, which ... I do not understand. If you know why, I'd be thrilled to update the spec. |
results = None | ||
try: | ||
results = list(pgcli.pgexecute.run("SELECT 1")) | ||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what exception we could get, here. If pgcli cannot connect to the server (or use the database), we'll fail when calling PGCLI.connect()
a few blocks before, not here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, @dbaty, it's extremely unlikely, but not impossible. I've seen this once in my life, and not with postgresql; database server was up, but the transaction log was full. I'm ok with keeping the try/catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, @dbaty, it's extremely unlikely, but not impossible. I've seen this once in my life, and not with postgresql; database server was up, but the transaction log was full.
@j-bennet : then it would be useful to log the exact error we got, instead of the misleading "could not connect to the database".
I am 100% fine with any of those changes; I'm not super familiar with the codebase, and it took me until earlier today to even figure out how to test it effectively. Feel free! I left "Allow edits by maintainers" enabled so you are more than welcome to push any changes that make sense to you! |
I pulled your branch, ran |
I don't, any more; I found the cause of my failure to write the tests correctly and pushed an update to it. |
Co-authored-by: Damien Baty <[email protected]>
Thanks to all of you for the cleanups and finalizing it! |
Description
This builds in the functionality asked for in #1470; it allows pgcli to replace
pg_isready
from the postgresql command line toolchainFixes: #1470
Checklist
changelog.rst
.AUTHORS
file (or it's already there).pip install pre-commit && pre-commit install
), and ranblack
on my code.