Copy and Share Data Sources in IntelliJ-based IDEs
In this tutorial we’re going to look at three popular use-cases:
— Duplicate a data source within one project.
— Share data sources between projects inside one IDE.
— Copy a data source from one IDE to another IDE, or to another computer.
Duplicate a data source within one project
A trivial problem deserves a trivial solution: in the context menu of the selected data source, click Duplicate or press Ctrl/Cmd+D.
A new data source will be created with the same properties, including the password.
Share data sources between projects inside one IDE
In IntelliJ-based IDEs, a data source can be global. This means it becomes visible from all projects you run from a particular IDE. By default, data sources are local. To make a data source global, click the corresponding button in the toolbar (or the context menu).
If you want to make it local again, click the button again.
Global data sources are visible in all projects you open from the same version of the same IDE. Say, if you use DataGrip 2020.1, global data sources will not be visible from projects you open in other versions of DataGrip or in IntelliJ IDEA.
Copy a data source from one IDE to another IDE, or to another computer
UPD: Starting from version 2021.1 you can:
- Select the needed data soucres.
- Copy them via Ctr/Cmd+C.
- Paste them in the needed IDE via Ctrl/Cmd+V.
- If the target IDE is on the another computer, just use the XML clipboard value produced on the step two.
Global data sources can be copied via Export Settings. But what if you don’t want to export all settings? And what if you don’t use global data sources?
The first and the most convenient way to copy data sources to another IDE: select the ones you need and in the context menu choose Database tools → Copy data source to clipboard.
In fact, XML is copied to the clipboard like in the following example:
You can send this snippet to your colleague via a messenger, or just import it to another IDE on your machine. To do this, click Add data source (+) → Import from clipboard.
The datasource is copied without a password, so you’ll need to input it manually. DataGrip stores passwords in the KeePass storage on Windows and in native keychains on Linux and MacOS. You can configure the IDE to store passwords in KeePass on any OS: to do this go to Settings/Preferences → Appearance and behavior → System settings → Passwords.
If for some reason that flow doesn’t meet your needs, here comes something for advanced users.
DataGrip, like any other IDE from JetBrains, works in the context of a project. The entity of the project is not a thing that database developers are used to, which is why DataGrip creates a default project once you run the IDE. And you continue using this default project unless you create a new one.
The information on all data sources you have in a project is stored inside the dataSources.xml file inside this project.
Where is this default project located?
More information about the config folders is here.
If you created other projects than default, we assume you know where they are located. Anyway, if you go to File → Open Recent → Manage projects, you’ll see all projects with their paths except the opened one.
So, if you open a project from another IDE, it will contain all data sources without passwords. They are stored in \.idea\dataSources.xml
If you make any changes to this file, it will affect the data sources you use. It can be even placed under a VCS to synchronize the data sources list between several users.
You might also notice the dataSources.local.xml file where DataGrip stores schema visibility settings and some other information that can vary from user to user. If a data source becomes global, the information about it is stored in the options folder, which is located at the same level as the projects folder.
That’s it. Please comment if you have questions.
Subscribe to Blog updates
Thanks, we've got you!
DataGrip 2023.3 EAP 2 is Out!
Hello, DataGrip community! The second Early Access Program version for DataGrip 2023.3 is here. If you want to try the new features before the official release, this is for you! Introspection scheduler It's now possible to set an introspection interval for each data source. Materialized…
DataGrip 2023.3 EAP is Open
Hello! We’re starting our 2023.3 Early Access Program (EAP) and, as usual, we invite you to try the latest features and improvements we’re adding to DataGrip ahead of the official release. Let’s take a look at what’s inside the first EAP build. DataGrip takes a long time to introspec…
DataGrip 2023.2: New UI with toolbar icons in the header, AI Assistant, time zones in the data editor, support for Redis Cluster
DataGrip 2023.2 is out!Here’s a sneak peek at what it has to offer. For a detailed description of this update, please visit our What’s New page. User Interface New UI: The toolbar icons have been moved to the header Improved main toolbar customization Light theme with light …
Nextсloud Performance Hacks with EverSQL and DataGrip
Hi, I'm Pasha. In my everyday life, I'm a Developer Advocate for data engineering, but by night, I'm a geek. Like, a really geeky geek! I have used Linux since 2009 as my primary OS (BTW I use Arch). If possible, I always prefer to host everything I use. So if you decide to drop me an email at me@as…