Skip to content
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 config option to always run with a single connection #1386

Merged

Conversation

andyscho
Copy link
Contributor

@andyscho andyscho commented Nov 26, 2022

Description

Add a config option for always running with a single connection. This is equivalent to always running with the --single-connection flag.

This is a very minor change, but this flag seems like it's the type of thing that would be useful to have persist as a regular config setting; for people that use it, it can be annoying to always have to specify it.

Leaving it defaulting to False to have the same behavior as before this change (not specifying the flag will not run in single-connection mode). When the config setting is False, users can still enable it in a non-persistent way by running with the flag in the same way as before.

Checklist

  • I've added this contribution to the changelog.rst.
  • I've added my name to the AUTHORS file (or it's already there).
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install), and ran black on my code.
  • Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

@codecov-commenter
Copy link

codecov-commenter commented Nov 26, 2022

Codecov Report

Base: 84.15% // Head: 79.69% // Decreases project coverage by -4.45% ⚠️

Coverage data is based on head (70748d8) compared to base (6884c29).
Patch coverage: 51.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1386      +/-   ##
==========================================
- Coverage   84.15%   79.69%   -4.46%     
==========================================
  Files          21       25       +4     
  Lines        2720     2975     +255     
==========================================
+ Hits         2289     2371      +82     
- Misses        431      604     +173     
Impacted Files Coverage Δ
pgcli/magic.py 0.00% <0.00%> (ø)
pgcli/packages/parseutils/tables.py 97.67% <ø> (ø)
pgcli/packages/sqlcompletion.py 97.67% <ø> (ø)
pgcli/pgstyle.py 64.00% <ø> (ø)
pgcli/pgtoolbar.py 31.57% <0.00%> (+0.15%) ⬆️
pgcli/pyev.py 15.38% <15.38%> (ø)
pgcli/explain_output_formatter.py 46.15% <46.15%> (ø)
pgcli/key_bindings.py 52.94% <66.66%> (-0.19%) ⬇️
pgcli/pgbuffer.py 67.85% <66.66%> (+1.19%) ⬆️
pgcli/main.py 78.73% <76.47%> (+0.19%) ⬆️
... and 11 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@andyscho
Copy link
Contributor Author

@j-bennet does this seem like a reasonable config addition?

@j-bennet
Copy link
Contributor

j-bennet commented Jan 2, 2023

@andyscho I'm ok with this option. Can you provide some use cases where it's necessary?

@andyscho
Copy link
Contributor Author

andyscho commented Jan 3, 2023

@j-bennet The main use case I had in mind when I made this pull request was a situation where the number of simultaneous connections a user can have to a database are limited. In this situation, it's probably helpful to basically always run it in single_connection mode (assuming there aren't any other issues with running in single_connection mode). Since it would be helpful to be able to enforce that the setting is always enabled, I think it seems reasonable to include it as a persistent config setting.

The single_connection option appears to have been introduced in #557, with the intention of the completer being able to function with one-time passwords when connecting to a database. I'm not particularly familiar with this specific use case, but it seems like it could be useful to still have ways to easily turn it on and off as a command line flag, as well as an optional persistent always-on config setting.

It seems okay to me to leave always-on mode OFF by default, as it seems possible there are other use cases where this would not really be an issue.

@j-bennet j-bennet merged commit 141873f into dbcli:main Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants