Skip to content

Conversation

@mlefebvre
Copy link

Description

Related issue: #247

I needed a way to execute commands on startup (like SET default_transaction_read_only = on when connecting on a production server), so I added a new startup_command configuration option.

Checklist

  • I've added this contribution to the changelog.rst.
  • [x 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 19, 2021

Codecov Report

Base: 84.15% // Head: 79.40% // Decreases project coverage by -4.74% ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1294      +/-   ##
==========================================
- Coverage   84.15%   79.40%   -4.75%     
==========================================
  Files          21       24       +3     
  Lines        2720     2904     +184     
==========================================
+ Hits         2289     2306      +17     
- Misses        431      598     +167     
Impacted Files Coverage Δ
pgcli/packages/parseutils/tables.py 97.67% <ø> (ø)
pgcli/packages/sqlcompletion.py 97.67% <ø> (ø)
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% <50.00%> (-0.19%) ⬇️
pgcli/main.py 78.44% <86.66%> (-0.09%) ⬇️
pgcli/pgexecute.py 83.22% <87.14%> (+2.86%) ⬆️
pgcli/auth.py 91.30% <91.30%> (ø)
pgcli/__init__.py 100.00% <100.00%> (ø)
... and 6 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.

Copy link
Contributor

@j-bennet j-bennet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A unit test for this feature would be helpful. You'd want to test a few use cases:

  • single command, valid SQL
  • single command, invalid SQL
  • multiline command.

For some examples, look at https://github.com/dbcli/pgcli/blob/master/tests/test_main.py.

@j-bennet
Copy link
Contributor

Hey @mlefebvre, do you need some help with this PR? This seems like a useful feature, would be nice to get it in.

@j-bennet
Copy link
Contributor

j-bennet commented Sep 2, 2022

Hi @mlefebvre, I tested your PR, things work fine. If you rebase on main, I'll merge this without a test.

@j-bennet j-bennet self-requested a review September 2, 2022 21:14
Copy link
Contributor

@j-bennet j-bennet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to rebase and merge.

@mlefebvre
Copy link
Author

Sorry @j-bennet , I had completely forgotten about this!

We found a different way to achieve what we wanted to do, so we didn't need the feature anymore.

@j-bennet
Copy link
Contributor

@mlefebvre

Thank you for getting back to me. If you don't intend to continue working on it, I'll close the PR.

Can you share how you solved this, so other users can benefit from your solution?

@j-bennet j-bennet closed this Sep 16, 2022
@danlamanna
Copy link

I'm also curious about solutions others have come up with, I tend to connect and immediately search history so I can run SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;.

@danlamanna
Copy link

For others following - this was implemented in #1504 🎉

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.

4 participants