CLI commands: manage
The manage command accepts a JSON input with a list of actions, executes them sequentially, and outputs a JSON array with results. This is the primary command for creating, modifying, and deleting data sources as well as managing driver artifacts.
- Syntax
- datagrip.exe dataSources manage -p <project_path> -i <input_path> -o <output_path>
- Example
- datagrip.exe dataSources manage -p C:\my_projects\cli_for_data_sources\ -i C:\data_source_jsons\input.json -o C:\data_source_jsons\output.json
- Syntax
- datagrip dataSources manage -p <project_path> -i <input_path> -o <output_path>
- Example
- datagrip dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/input.json -o ~/data_source_jsons/output.json
- Syntax
- datagrip.sh dataSources manage -p <project_path> -i <input_path> -o <output_path>
- Example
- datagrip.sh ataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/input.json -o ~/data_source_jsons/output.json
Options
- -p, --project
Path to the project directory.
Required: Yes
- -i, --input
Input file path. If omitted, DataGrip from stdin.
Required: No
- -o, --output
Output file path. If omitted, DataGrip writes to stdout.
Required: No
- --input-schema
Returns JSON schemas that can be used to validate input JSON.
Required: No
- --output-schema
Returns JSON schemas that can be used to validate output JSON.
Required: No
The --input-schema and --input-schema options do not manage data sources, so -p, -i, and -o are ignored when used with them.
Input format
In the actions array, each element is a JSON object with a single key which is the action name. This key's value is the object of action parameters.
Output format
For the manage command, the output format is a JSON array in which each element corresponds to an action from the input. In output and input, the elements and actions are listed in the same order.
In case of success, the entry contains "result" with the action-specific result data. In case of failure, the entry contains "error" with an error message.
For the list of supported actions, refer to Actions.
Common types
DataSourceFilter
DataGrip uses this filter to match data sources. To match a data source, all specified fields must match. If all fields are null, the filter matches nothing.
The fields contain information about a data source:
- id
Unique identifier.
- name
Display name.
- dbmsName
DBMS name. For example,
"POSTGRES","MYSQL", or"ORACLE". Case-sensitive.
UpdatedDataSourceInfo
Returned after the create or modify operations.
The fields contain information about a data source:
- id
Unique identifier.
- name
Display name.
- url
JDBC URL.
Actions
createDataSource
Creates a new data source in the project.
Parameters
- name
Display name for the new data source.
- driverId
Explicit driver ID. If provided, the
dbmsNameparameter is ignored.- dbmsName
The DBMS name used for automatic driver search. For example,
"POSTGRES","MYSQL".- url
JDBC URL.
Either
urlorconnectionParamsmust be provided.- connectionParams
Key-value connection parameters used to create the URL using the driver's URL template.
Driver is resolved by using the driverId and dbmsName fields. If driverId is provided, dbmsName is ignored and the driver is looked up by the provided ID. Otherwise, the driver is resolved by matching dbmsName or url against registered drivers.
URL is resolved by using the url and connectionParams fields. If url is provided, it is used directly. If connectionParams is provided and url is not, the URL is built from the resolved driver's URL template using the given parameters. If neither of the parameters is provided, an error is returned.
The result of this command in a JSON output is as follows:
Example
Input JSON file action_create_in.json:
{ "actions": [ { "createDataSource": { "name": "My PostgreSQL", "dbmsName": "POSTGRES", "url": "jdbc:postgresql://localhost:5432/mydb" } } ] }CLI command:
datagrip.exe dataSources manage -p C:\my_projects\cli_for_data_sources\ -i C:\data_source_jsons\action_create_in.json -o C:\data_source_jsons\action_create_out.jsondatagrip dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/action_create_in.json -o ~/data_source_jsons/action_create_out.jsondatagrip.sh dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/action_create_in.json -o ~/data_source_jsons/action_create_out.jsonOutput JSON file action_create_out.json:
[ { "action": "createDataSource", "result": { "createdDataSource": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "name": "My PostgreSQL", "url": "jdbc:postgresql://localhost:5432/mydb" } } } ]
deleteDataSource
Deletes data sources that match the provided filters. Each filter is evaluated independently. A data source is deleted if it matches any of the filters.
Parameters
- filters
List of filters. A data source is deleted if it matches any of the provided filters.
Example
Input JSON file action_delete_in.json:
{ "actions": [ { "deleteDataSource": { "filters": [ { "name": "Old Database" }, { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890" } ] } } ] }CLI command:
datagrip.exe dataSources manage -p C:\my_projects\cli_for_data_sources\ -i C:\data_source_jsons\action_delete_in.json -o C:\data_source_jsons\action_delete_out.jsondatagrip dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/action_delete_in.json -o ~/data_source_jsons/action_delete_out.jsondatagrip.sh dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/action_delete_in.json -o ~/data_source_jsons/action_delete_out.jsonOutput JSON file action_delete_out.json:
[ { "action": "deleteDataSource", "result": { "deletedIds": [ "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "b2c3d4e5-f6a7-8901-bcde-f12345678901" ] } } ]
modifyDataSource
Parameters
The modifyDataSource modifies an existing data source. The filter criteria must match exactly one data source. If none or more than one data source matches the criteria, an error is returned.
At least one of these fields must be provided: name, url, driverId, or connectionParams.
- filter
Filter to identify the data source. The criteria must match exactly one data source.
- name
New display name.
- driverId
New driver ID. Changes the driver associated with the data source.
- url
New JDBC URL.
- connectionParams
Key-value connection parameters. These parameters help build a new URL using the current driver's URL template.
The field is ignored if the
urlfield. is also provided.
URL is updated using url or connectionParams field. If the url field is provided, it is used directly. If only connectionParams is provided, the current driver's URL template is used to create a new URL from the parameters. If driverId is also provided, the driver is updated first, then connectionParams uses the new driver.
The result of this command in a JSON output is as follows:
Example
Input JSON file action_modify_in.json:
{ "actions": [ { "modifyDataSource": { "filter": { "name": "My PostgreSQL" }, "name": "Production PostgreSQL", "url": "jdbc:postgresql://prod-host:5432/mydb" } } ] }CLI command:
datagrip.exe dataSources manage -p C:\my_projects\cli_for_data_sources\ -i C:\data_source_jsons\action_modify_in.json -o C:\data_source_jsons\action_modify_out.jsondatagrip dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/action_modify_in.json -o ~/data_source_jsons/action_modify_out.jsondatagrip.sh dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/action_modify_in.json -o ~/data_source_jsons/action_modify_out.jsonOutput JSON file action_modify_out.json:
[ { "action": "modifyDataSource", "result": { "modifiedDataSource": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "name": "Production PostgreSQL", "url": "jdbc:postgresql://prod-host:5432/mydb" } } } ]
updateArtifactList
Refreshes the list of available database artifacts (drivers) from the remote repository. This action takes no parameters and should typically be called before downloadArtifacts or setUpRecommendedArtifacts to ensure the artifact catalog is up to date.
Parameters
None. Empty object {}.
The result of this command in a JSON output is as follows:
Example
Input JSON file action_updateArtifacts_in.json:
{ "actions": [ { "updateArtifactList": {} } ] }CLI command:
datagrip.exe dataSources manage -p C:\my_projects\cli_for_data_sources\ -i C:\data_source_jsons\action_updateArtifacts_in.json -o C:\data_source_jsons\action_updateArtifacts_out.jsondatagrip dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/action_updateArtifacts_in.json -o ~/data_source_jsons/action_updateArtifacts_out.jsondatagrip.sh dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/action_updateArtifacts_in.json -o ~/data_source_jsons/action_updateArtifacts_out.jsonOutput JSON file action_updateArtifacts_out.json:
[ { "action": "updateArtifactList", "result": { "status": "ok" } } ]
downloadArtifacts
Downloads specific database artifacts (for example, JDBC driver JARs) using their artifact tokens.
Parameters
- artifactTokens
List of artifact tokens to download.
The following formats of artifact tokens are supported:
<artifactId>: Resolves to the latest stable version.<artifactId>:<version>: Resolves to a specific version.<artifactId>:<channel>: Resolves to the latest version in the given channel.<artifactId>:<version>/<channel>: Resolves to a specific version in the given channel.
The result of this command in a JSON output is as follows:
The resulting JSON contains these fields:
- artifactId
Artifact identifier.
- version
Downloaded version. If resolution failed, the value is
null.- state
The resulting state:
"Downloaded"or"Failed".- error
Error message. Present only when
stateis"Failed".
Example
Input JSON file action_downloadArtifacts_in.json:
{ "actions": [ { "downloadArtifacts": { "artifactTokens": ["com.mysql:8.0.33", "org.postgresql"] } } ] }CLI command:
datagrip.exe dataSources manage -p C:\my_projects\cli_for_data_sources\ -i C:\data_source_jsons\action_downloadArtifacts_in.json -o C:\data_source_jsons\action_downloadArtifacts_out.jsondatagrip dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/action_downloadArtifacts_in.json -o ~/data_source_jsons/action_downloadArtifacts_out.jsondatagrip.sh dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/action_downloadArtifacts_in.json -o ~/data_source_jsons/action_downloadArtifacts_out.jsonOutput JSON file action_downloadArtifacts_out.json:
[ { "action": "downloadArtifacts", "result": { "downloadedArtifacts": [ { "artifactId": "com.mysql", "version": "8.0.33", "state": "Downloaded" }, { "artifactId": "org.postgresql", "version": "42.7.1", "state": "Failed", "error": "Connection timeout" } ] } } ]
setUpRecommendedArtifacts
Downloads and configures the recommended (latest stable) artifacts for the specified database drivers. This is useful for initial driver setup or updating drivers to recommended versions.
Parameters
- driverIds
List of driver IDs to set up.
The result of this command in a JSON output is as follows:
The resulting JSON contains these fields:
- id
Driver ID.
- name
Driver display name. If the driver was not found, the value is
null.- state
The resulting state:
"Downloaded": New artifacts were downloaded and configured."UpToDate": The driver already had the recommended artifacts."Failed": The operation failed. For example, the driver ID was unknown.
- error
Error message. Present only when
stateis"Failed".
Example
Input JSON file action_setupArtifacts_in.json:
{ "actions": [ { "setUpRecommendedArtifacts": { "driverIds": ["postgresql", "mysql.8"] } } ] }CLI command:
datagrip.exe dataSources manage -p C:\my_projects\cli_for_data_sources\ -i C:\data_source_jsons\action_setupArtifacts_in.json -o C:\data_source_jsons\action_setupArtifacts_out.jsondatagrip dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/action_setupArtifacts_in.json -o ~/data_source_jsons/action_setupArtifacts_out.jsondatagrip.sh dataSources manage -p ~/my_projects/cli_for_data_sources/ -i ~/data_source_jsons/action_setupArtifacts_in.json -o ~/data_source_jsons/action_setupArtifacts_out.jsonOutput JSON file action_setupArtifacts_out.json:
[ { "action": "setUpRecommendedArtifacts", "result": { "updatedDrivers": [ { "id": "postgresql", "name": "PostgreSQL", "state": "Downloaded" }, { "id": "mysql.8", "name": "MySQL 8", "state": "UpToDate" } ] } } ]