-
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 support for overriding DSN connection information #1352
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1352 +/- ##
==========================================
- Coverage 84.15% 79.71% -4.45%
==========================================
Files 21 25 +4
Lines 2720 3036 +316
==========================================
+ Hits 2289 2420 +131
- Misses 431 616 +185
☔ View full report in Codecov by Sentry. |
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.
remap.get(k, k): v | ||
for k, v in kwargs.items() | ||
if ctx.get_parameter_source(k) is click.core.ParameterSource.COMMANDLINE | ||
} |
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.
can you add testcases for this part? thanks
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.
Well, I add a script to test this part, I mock PGCli.connect_uri
to verify that whether using -D dsn
along with -h
-p
-u
-d
-W
can override the connection information of dsn
. But I'm not familiar with pytest, so let me know if there are any problems in my test script
Specifically, on a test machine, we have many instances of the PostgreSQL service running on random ports (when creating an instance, our administration system randomly selects an available port for that instance), so I can't easily connect to each instance by setting multiple DSN. I hope that when using a DSN whose IP address is set to our test machine to connect, I can specify the port obtained from our administration system with the |
@laixintao @A-23187 I agree, this sounds like a valid use case. Are you able to add a test for this, @A-23187 ? |
Sure, I added a script to test this. |
Description
When connecting using a DSN alias, you can specify additional options (including
-h
,-p
,-u
,-W
and-d
) to override the connection information represented by the DSN you used. For example,pgcli -D dsn -p 54321
means to connect using the aliasdsn
, while the port is overridden as54321
. It is very useful for me because I have multiple PostgreSQL services deployed on a single server that listen on different ports, I just need to configure only one DSN alias and specify different ports via the-p
option to connect to these services.Checklist
changelog.rst
.AUTHORS
file (or it's already there).pip install pre-commit && pre-commit install
), and ranblack
on my code.