Manage data sources
Data source is a location of data for your application. In PhpStorm, you can define the following data sources:
Database data source: operational databases that contain data (see Database connection).
Data Definition Language (DDL) files: SQL files that contain data definition language statements.
Configure display options for data sources
You can group, assign a color, and filter objects in the Database tool window ( ).
Customize the view of objects in the Database tool window
To group, enable, or sort data sources, click the Show Options menu icon on the title bar of the Database tool window and select the necessary options.
In the Database tool window ( ), the view of the data source changes instantly.
For more information about the view options, see View options.
Group data sources in folders
In the Database tool window ( ), 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 Ctrl+C, Ctrl+V, and Ctrl+X to copy, paste, and cut your data sources between folders. If you cut and paste a data source inside one project, it will be just moved, no password is required. But the password is required in all the other cases. The cut operation can be undone by using Ctrl+Z.
Assign a color to a data source
To have better differentiation between production and test databases, you can assign a color to a data source.
In the Database tool window ( ), click the Data Source Properties icon .
Select the data source for which you want to assign a color.
Click the circle in the Name field to select a color.
Assign a color to query consoles and grids
The text data viewer can use the color of the data source. To set a color, right-click a data source and select Color Settings…. In the Database Color Settings dialog, select the dialog and coloring options. To have the data source color applied for query consoles and grids, select the In console editors and grids checkbox.
Filter objects from the toolbar
To select the necessary objects, use the Filter icon on the toolbar .
Show comments for data sources and database objects
To enable descriptions for databases and tables, navigate to Descriptions in Tree Views.
and selectTo add comments for tables, select a table and press Ctrl+F6. In the Comment text field, add a table description.
To add comments for a database, open database settings Ctrl+Alt+S and add a database description in the Comment text field.
Use full names of data sources
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.
View contents of a node in Database
In the Database tool window ( ), click a node that groups database objects, and press F4.
Share data sources
Data sources in PhpStorm 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 to it, such as its accessibility level (project or global), the user, database connection and schema settings, and so on.
Make a copy of a data source
In the Database tool window ( ), click the Data Source Properties button ().
In the Data Sources and Drivers window, select the data source that you want to copy.
Click the Duplicate icon (), or press Ctrl+D.
Share data sources between projects
In the Database tool window ( ), 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.
Share data sources between different IDE instances
You can copy information about a data source to the clipboard in the XML format. The resulted XML does not include password information.
You can send the XML snippet to another IDE (in a messenger or by email) and import it.
In the Database tool window ( ), select data sources that you want to copy.
Press Ctrl+C. Alternatively, right-click the selection and navigate to Copy Data Source.
On another workstation, click
.In the Database tool window, click the New icon , select Import from Clipboard. Alternatively, right-click the Database tool window and select Paste Data Source (or press Ctrl+V).
Sharing data source settings
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 how to change a level, see Change the project level to global.
Export data source settings
Click
.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 in the list.
In the Export settings to field, type a path to the folder where you want to store the settings.zip file.
Import data source settings
Click
.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.
Tips and tricks
Share all the connections with passwords
Open settings by pressing Ctrl+Alt+S and navigate to
.Select the In KeePass option.
In the Database field, type a path for the KDBX file. Select a path where you store your project. By default,PhpStorm stores your projects under ~\DataGripProjects.
Copy the whole folder with your project from ~\DataGripProjects to another computer.
On another computer, open settings by pressing Ctrl+Alt+S and navigate to
.In the Database field, type a path to the copied KDBX file.
Click
and navigate to the directory with copied project files.