Using Postgres PSQL CLI in DataGrip
I have seen in the pgAdmin the very convenient way to use psql with right click context in a database. I can't find a way in the datagrip and it is very annoying to have always open the pgAdmin for that reason. I have used the External Tools way but it doesn't work as I want. It is appeared in main tool bar and it doesn't work with argument macros like -h $DS_HOST$ -p $DS_PORT$ -U $DS_USER$ -d $DS_DATABASE$
请先登录再写评论。
That's correct. You need to set up psql as External Tool and use the macros available in our IDE:
https://www.jetbrains.com/help/datagrip/built-in-macros.html
The specific arguments you mentioned are not listed, so you have to add your own custom macros. May I know what your use case is?
Thank you for your response but about “May I know what your use case is?” I think that I was very clear! Nevertheless it looks like rocket science in compare to the FREE pgAdmin.
DataGrip doesn’t have a native “Open psql here” feature like pgAdmin. The best workaround is an External Tool opened from the Database context menu using macros like
$Host$,$Port$,$User$, and$Database$instead of$DS_*. That works much more reliably in newer versions.https://youtrack.jetbrains.com/issue/DBE-13452/Open-psql-terminal-session-from-connection
Unfortunately, DataGrip doesn't currently offer a native right-click "Open psql" option like pgAdmin. If the External Tools macros aren't working in your setup, it may be a limitation of the available macros or how they're resolved for database connections. You might want to check the JetBrains issue tracker for existing feature requests or submit one yourself. A built-in psql launcher tied to the selected data source would definitely be a useful addition for PostgreSQL users.
DataGrip’s external tools don’t behave exactly like pgAdmin’s right-click psql option. The
$DS_*macros usually need an active database context, so running it from the toolbar won’t resolve them. Try invoking it from the Database view after selecting the data source, or use DataGrip’s built-in query console/terminal integration instead.