Ability to connect to a database from the command line
Answered
Is there any way to connect to the database from the command line. I'm basically looking for the following behavior.
datagrip [ProfileName|jdbcConnectionString|fileName] [--new-console]
Then it opens up the existing datagrip, or starts up data grip. It then looks for the connection name, the connection that matches the jdbc string, or the file if its sqlite, MS Access or simalar. it then creates a connection profile if it doesn't exist. It them opens a tab for the console for that database and makes it the active tab. If you specify --new-console it creates a new console for that connection.
Does anything like this exist? A plugin or whatever?
Please sign in to leave a comment.
Hi,
Do you want to automate some routines?
Currently, we don't have anything similar.
Thank you.
We need this to easily connect to different environments without having to click around the GUI.
@ Slobodan
Could you describe your flow in more details?
(@vasily chernov Sorry missed your comment somehow.)
What we currently do is we start our database in the container with a dynamic port in development. Sometimes we even have multiple copies of the database for different branches.
Our internal tooling can tell me the host and port number for each database, and then I have to edit the Data Source in the UI to change to the new port number. Have to do this every time we restart container, which could be more than once per day.
Ability to do as @Zippy1981 described would let us create short shell command to connect to any given db.
pseudocode of what we'd like to be able to do:
> datagrip $(connection-string-for postgres-1)
Bonus points if it can be associated with existing console / update existing profile. Hope that makes sense
Thanks
Would be interested as well. We generate dynamic credentials valid for 2 hours using Hashicorp Vault.
It would be cool to open a connection right away in DataGrip from the CLI.
We can already open connections from TablePlus by doing the following as they register the mysql:// schema handler
Or from Querious by doing:
Or from Sequel Pro by creating an template .plist file: https://gist.github.com/messageagency/6223d272b79fe6f7bb2b
I am interested as well. To the best of my knowledge, the only workaround right now is to update the XML file in a location ${HOME}/Library/Preferences/DataGrip2019.3/projects/default/.idea/dataSources.xml
Would like to see more CLI support as well. Would like the ability to connect/disconnect from a data source.
I have sql script which I run to restore a db in my dev environement but it won't run if datagrip is connected.
So right now I have to either disconnect or close datagrip, run my restore script, then reconnect/restart datagrip.
Would be nice to do something like: datagrip --disconnect datasource, datagrip --connect datasource
We have a similar scenario to @... where host and port is dynamically allocated and we need to go in and modify the data source each time we want to connect.
Having a CLI option to connect to a datasource but override the connection string would be ideal for our case.
There is an issue https://youtrack.jetbrains.com/issue/DBE-7685 you can vote for and follow.
vasily chernov Cool, thanks!