Open
Conversation
pgcli now requires psycopg3, whose `Connection` object does not have a `session` attribute. We can retrieve the URL directly from the `Connection` object.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
(Context: pgcli provides integration with IPython, see https://www.pgcli.com/ipython.)
pgcli now requires psycopg3, whose
Connectionobject does not have asessionattribute. We can retrieve the URL directly from theConnectionobject. (Test is hard to write, because it requires a PostgreSQL server to connect to. We could mock a few functions here and there, but I am not interested in going this direction, see below.)This fixes the bug reported in #1520:
Click to toggle demo output
Note that I did not input any SQL query above. But the IPython integration is still half-broken when one does input an SQL query:
Click to toggle demo output
This is because of a bug in ipython-sql.
ipython-sqlseems to be unmaintained, people suggest using a fork:jupysql. I tried, but it's not a drop-in replacement: I get an AttributeError onsql.connection.Connectioninpgcli.magic.pgcli_line_magic().I do not use IPython, so I am not willing to go further. This pull request makes pgcli available from IPython, even though SQL results cannot be used back in IPython. This is not perfect (and certainly limited), but it's still better than the current situation.
Checklist
changelog.rst.AUTHORSfile (or it's already there).pip install pre-commit && pre-commit install).Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)