pgcli icon indicating copy to clipboard operation
pgcli copied to clipboard

pgcli's equivalent to mycli's `--init-command`?

Open your-diary opened this issue 8 months ago • 4 comments

mycli supports --init-command option:

--init-command TEXT             SQL statement to execute after connecting.
  • Does pgcli have this?

  • Is it possible to specify the init commands in the config file ~/.config/pgcli/config? Ideally I want to specify different --init-command for different DSNs defined in [alias_dsn].

your-diary avatar Mar 19 '25 03:03 your-diary

pgcli does not have the feature. I imagine it would not be difficult to port from mycli, if you have the bandwidth.

Here is the mycli PR adding the feature:

https://github.com/dbcli/mycli/pull/874

j-bennet avatar Mar 22 '25 16:03 j-bennet

@your-diary Can you try this pull-requests and let me know if that satisfies your request?

You can install pgcli from this branch using the following command:

pip install -U https://github.com/dbcli/pgcli/archive/refs/heads/amjith/init-command.zip

amjith avatar Apr 20 '25 00:04 amjith

@amjith Thank you for your great work! It's working as expected :)


Dockerfile and compose.yaml files used for testing: https://github.com/dbcli/mycli/issues/1195#issuecomment-2816959292

your-diary avatar Apr 20 '25 02:04 your-diary