Connecting DataGrip to Azure Cosmos DB?

DataGrip can sign into Azure SQL Server pretty well, but how do you connect to Azure Cosmos DB? 

4
10 comments

If there is a JDBC driver for Cosmos DB you can connect and work with it. 

0

I could really use this feature - the years keep spinning by and I still can't access. Any ETA on Cosmos DB access, even the cosmos db emulator would be a big plus.

0

You can use Azure CosmosDB jdbc driver for connection from within DataGrip

Are there any steps on how to do this? I don't see any CosmosDB JDBC driver in the driver list…

0

Greg 

I don't see any CosmosDB JDBC driver in the driver list

That is because there is no out-of-the-box support for this type of database in DataGrip (which is what DBE-6857 is about).

What you can do now is:

  1. Download the JDBC driver here: https://www.cdata.com/drivers/cosmosdb/jdbc/
  2. Add it as a new User Driver in Datagrip: https://www.jetbrains.com/help/datagrip/other-databases.html#using-user-driver-files
  3. Add a new Data Source based on the added driver: https://www.jetbrains.com/help/datagrip/managing-data-sources.html#create_a_data_source
  4. Configure the connection according to your needs: https://www.jetbrains.com/help/datagrip/configuring-database-connections.html
1

Arina Efremova 

There are 3 main ways to connect to a CosmosDB: Postgres, NoSQL, and Mongo - depends on how the instance was created.

 

I just created all 3 test Cosmos DBs and I was able to connect to all of them. Postgres and Mongo can use the included with DataGrip drivers for those databases just fine. But the https://www.cdata.com/drivers/cosmosdb/jdbc/ driver for the NoSQL version, which has no username/password and uses this format instead jdbc:cosmosdb:AccountEndpoint=myAccountEndpoint;AccountKey=myAccountKey; connects without showing any data. It requires to fill in its Advanced options and also plug the URL field in this format:

 

When I try to view Schemas/Data I get this error: “[HY000] The function 'db_id' is not supported.”

 

CData is not a free driver though, not to mention it simply does not work (at least I could not find the right options to make it work). There seems to be an existing Cosmos DB driver for Intellij https://devblogs.microsoft.com/cosmosdb/intellij-idea-support/ - can it be used here? Are there any other drivers you or someone could recommend to connect to a NoSQL CosmosDB?

0

Hi Sergey Ivanov 

Did you try using the mentioned Azure ToolKit for IntelliJ plugin to resolve this?

0

I could not find the jar file from that plugin.

Arina Efremova you recommended https://www.cdata.com/drivers/cosmosdb/jdbc/. Any examples of a successful usage?

0

Sergey Ivanov 

As far as I know, Azure Toolkit does not provide any JDBC drivers. They provide additional connection properties and matching connectivity logic.

We haven't officially tested this driver. You can collect the driver logs and upload them to https://uploads.jetbrains.com so that we can take a look at how exactly the driver reacts to our connection request.

Since you have a specific use case with a particular error code, you can also try contacting CData support. Maybe they can advise something.

0

Please follow the steps outlined below to seamlessly connect to Cosmos DB using the CData JDBC Driver for Cosmos DB:

  1. Download and Install CData JDBC Driver for Cosmos DB:
  2. Create a User Driver in Datagrip:
    • Upload the installed CData JDBC Driver for Cosmos DB to create a User Driver in Datagrip.
  3. Navigate to the Advanced Tab and Access Expert Options:
    • In Datagrip, navigate to the Advanced tab and click on Expert Options located in the bottom right corner.
    • Set the DBMS property to UNKNOWN and apply the changes.
    • Note: This step is crucial as it resolves the identified issue.
  4. Create a Data Source Using the Driver:
    • With the adjustments made in the Expert Options, you can now proceed to create a data source using the CData JDBC Driver.
    • Generate the Connection String using the JAR file in the driver's installation directory OR by directly setting the properties in the Advanced tab.
      • Default Directory: C:\Program Files\CData\CData JDBC Driver for Azure Cosmos DB 2023\lib\cdata.jdbc.cosmosdb.jar
  • Data Retrieval

These steps should be followed for each CData JDBC Driver.

By following these steps, you should be able to establish a connection to Cosmos DB. If you encounter any difficulties you can reach out to support@cdata.com.

0

Please sign in to leave a comment.