Skip to content

pgcli's equivalent to mycli's --init-command? #1499

Description

@your-diary

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].

Activity

  1. j-bennet commented on Mar 22, 2025

    @j-bennet
    Contributor

    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:

    dbcli/mycli#874

  2. amjith commented on Apr 20, 2025

    @amjith
    Member

    @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
    
  3. your-diary commented on Apr 20, 2025

    @your-diary
    Author

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


    Dockerfile and compose.yaml files used for testing: dbcli/mycli#1195 (comment)

  4. your-diary commented on Dec 11, 2025

    @your-diary
    Author

    Is there any plan to release the change?
    The PR has already been merged.

    ref: changelog.rst

  5. j-bennet commented on Dec 24, 2025

    @j-bennet
    Contributor

    Good point. Release coming up: #1548.

  6. j-bennet commented on Dec 24, 2025

    @j-bennet
    Contributor

    4.4.0 is out to pypi. Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions