Data sources
Create and configure data sources in the Data Sources and Drivers dialog (CtrlAltShift0S) dialog.
Use Ctrl0C, Ctrl0V, and Ctrl0X to copy, paste, and cut your data sources. See the following video about copying and pasting data sources at youtube.com.
A data source is copied into the clipboard as XML, you can share it in a messenger or paste in the other JetBrains IDE.
Data source is a connection configuration. It stores a list of connection details that are used to establish connection to a database. For example, host, port, database name, driver, SSH and SSL configuration settings, and so on. In data source settings, you can also select databases and schemas for introspection and display in Database Explorer, and change the driver for your connection.
You can configure your data sources in the Data Sources and Drivers dialog (CtrlAltShift0S) . To access the dialog, in the Database Explorer (View | Tool Windows | Database Explorer) , click the Data Source Properties button () on the toolbar.
You can see the list of created data sources in the Database Explorer (View | Tool Windows | Database Explorer) . Data sources with an active connection to a database are marked with a green dot in the corner of their icons.
In DataGrip, you can create the following data sources:
Database data sources: connection configurations for the operational databases that contain data.
For different database vendors, DataGrip provides complete support and basic support. Complete support of a database vendor includes such features as enhanced code completion and better retrieval of database objects (introspection). All the inspections, quick-fixes, and other coding assistance features are also available. Whereas basic support has limited features available.
For more information on the support types, refer to the Other databases topic.
Data Definition Language (DDL) data sources: SQL files that contain data definition language statements (refer to DDL data sources).
To connect to a database and start working with it, create a data source that will contain the connection details and specify those details for the database that you are connecting to.
The following video is a general instruction on adding a data source. For illustrative purposes, the video shows how to add a PostgreSQL data source.
note
In the video, the DataGrip user interface is Classic UI. Starting from version 2023.1, the New UI is available. For more information about the New UI, refer to the corresponding topic.
Follow the instructions for the database vendor.
DataGrip provides complete support for the following database vendors:
For the database vendors listed below, a basic support is provided:
AWS Athena
Apache Ignite
Apache Spark
DuckDB
Elasticsearch
Firebird
Google Cloud Spanner
Informix
InterSystems IRIS
Mimer SQL
OpenEdge
Phoenix
Presto
SAP HANA
SingleStore
Tarantool
Teradata
TiDB
Tibero
Trino
YugabyteDB
To create a DDL data source, follow the instructions from the DDL data sources topic.
You can group, assign a color, and filter objects in the Database Explorer (View | Tool Windows | Database Explorer).
To group, enable, or sort data sources, click the Options icon () on the header of the Database Explorer and select the necessary options.
In the Database Explorer (View | Tool Windows | Database Explorer) , the view of the data source changes instantly.
For more information about the database tree view options, refer to View Options.
In the Database Explorer (View | Tool Windows | Database Explorer) , select the necessary data source and press F6. Alternatively, right-click a data source and select Move to Folder.
If you do not have any folders, you will see the New Folder dialog. In the text field, type the folder name. You can use a forward slash (
/
) to define nesting. For example, theQA/Quick
name will create theQuick
folder inside theQA
folder.If you have folders with grouped data sources, you will see the Move to Folder dialog. To create a new folder, select New Folder. To remove a data source from the folder, select Root folder.
Also, you can use Ctrl0C, Ctrl0V, and Ctrl0X to copy, paste, and cut your data sources between folders. If you cut and paste a data source inside one project, it will be moved. No password is required. But the password is required in all the other cases. The cut operation can be undone by using Ctrl0Z.
To have better differentiation between production and test databases, you can assign a color to a data source.
You can so it either by using data source's settings dialog or its context menu.
Settings dialog
In Data Sources and Drivers dialog (CtrlAltShift0S) , select the data source for which you want to assign a color.
Click the circle in the Name field to select a color.
Apply the changes and close the dialog.
Context menu
In Database Explorer, right-click the data source and navigate to Tools | Set Color.
In Color, select the color that you want to assign.
Apply the changes and close the dialog.
tip
For more examples about using colors with data sources, refer to the following video at youtube.com.
The code editor and data editor tabs can use the color of the data source.
To apply the data source color for query consoles and grids, right-click a data source and select Tools | Set Color.
In the Database Color Settings dialog, select the In console editors and grids checkbox.
Apply the changes and close the dialog.
For more information about the dialog and options, refer to Database Color Settings dialog
For more information about about the appearance settings in the dialog, refer to Database Color Settings dialog.
To select the necessary objects, use the Filter icon on the toolbar .
To enable comments for databases and tables, click the Options icon () on the header of the Database Explorer and select Comments.
To add comments for tables, select a table and press CtrlF6. In the Comment text field, add a table description.
To add comments for a database, open database settings CtrlAlt0S and add a database description in the Comment text field.
By default, the Shorten Tab Titles option is enabled. A data source name in the tab title is shortened to 36 characters.
Right-click a tab of a query console and select Shorten Tab Titles.
In the Database Explorer (View | Tool Windows | Database Explorer) , click a node that groups database objects, and press F4.
Data sources in DataGrip are available at two levels: project and global. The project level means that you can access a data source only from the project where this data source was created initially. At the global level, a data source is available for other projects. By default, a data source is available at the project level.
To share a data source between different projects inside your IDE, you need to move the data source to the global level.
You can copy a data source if you need to use the same data source in another project but have different requirements for it, such as its accessibility level (project or global), the user, database connection and schema settings, and so on.
In the Database Explorer (View | Tool Windows | Database Explorer) , click the Data Source Properties button ().
In the Data Sources and Drivers window, click the Make Global icon () to make the data source available at the global level. Click the icon again to change the level to project.
The project level means that you can access a data source only from the project where this data source was created initially. At the global level, a data source is available for other projects. By default, a data source is available at the project level.
You can copy information about a data source to the clipboard in the XML format.
The resulted XML does not include password information, unless it was provided within a JDBC URL for the URL only connection type. For more information about this connection type, refer to Data Source and Drivers dialog reference topic.
You can send the XML snippet to another IDE (in a messenger or by email) and import it.
In the Database Explorer (View | Tool Windows | Database Explorer) , select data sources that you want to copy.
Press Ctrl0C. Alternatively, right-click the selection and navigate to Copy/Paste | Copy Data Source.
On another workstation, click View | Tool Windows | Database Explorer.
In the Database Explorer, click the New icon (), select Import from Clipboard. Alternatively, right-click the Database Explorer and select Copy/Paste | Paste Data Source (or press Ctrl0V).
note
DataGrip stores passwords in native keychains on macOS and Linux and in the KeePass storage on Windows. You can configure your IDE to store passwords in KeePass (File | Settings | Appearance & Behavior | System Settings | Passwords).
You can delete a data source in one of the following ways:
To delete the data source using its context menu, in the Database Explorer (View | Tool Windows | Database Explorer) , right-click the data source that you want to delete and select Delete Data Source.
To delete a data source in the Data Sources and Drivers dialog, follow these steps:
Open data source properties. You can open data source properties by using one of the following options:
Navigate to File | Data Sources....
Press CtrlAltShift0S.
In the Database Explorer (View | Tool Windows | Database Explorer), click the Data Source Properties icon ().
In the left pane of the dialog, select the data source that you want to delete and click the Remove icon () in the toolbar.
To delete a data source in the Data Sources and Drivers dialog via its context menu, in the left pane of the dialog, right-click the data source that you want to delete and select Remove.
tip
You can also select the data source that you want to delete and press Delete.
You can export and import data source settings by using the settings.zip file. The settings.zip file includes only data sources that are available at the global level. For more information about changing a level, refer to Change the project level to global.
note
You can export only global data sources. If you have no global data sources or no drivers, you will not see Database: global data sources and Database: drivers in the export list.
Click File | Manage IDE Settings | Export Settings.
In the Export Settings window, click Select None.
In the Export Settings window, select Database: drivers, Database: settings, and Database: global data sources. You must have at least one global data source to have Database: global data sources in the export list. Also, ensure that you downloaded or created at least one driver. Otherwise, the Database: drivers menu item will not appear on the list.
In the Export settings to field, type a path to the folder where you want to store the settings.zip file.
Click File | Manage IDE Settings | Import Settings.
In the Import File Location window, locate the settings.zip file that you exported, and double-click it.
In the Select Components to Import window, select Database: drivers, Database: settings, and Database: global sources.
Click OK.
In the Restart Needed window, click OK to restart your IDE.
Open the Data Sources and Drivers window, enter necessary connection credentials in the data source properties. If the data source is on a local or network drive, ensure that the path to this data source is correct.
To ensure that the connection to the data source is successful, click Test Connection.
Open settings by pressing CtrlAlt0S and navigate to Appearance & Behavior | System Settings | Passwords. .
Select the In KeePass option.
In the Database field, specify a path for the KDBX file in the directory where you store your project. By default, DataGrip stores your projects under ~\DataGripProjects.
Copy the whole folder with your project from ~\DataGripProjects to another computer.
On another computer, open settings by pressing CtrlAlt0S and navigate to Appearance & Behavior | System Settings | Passwords. .
In the Database field, type a path to the copied KDBX file.
Click File | Open and navigate to the directory with copied project files.
Thanks for your feedback!