cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Is it possible to connect QGIS to Databricks using ODBC?

gfar
New Contributor II

I can connect ArcGIS to Databricks using ODBC, but using the same ODBC DSN for QGIS I get an error - Unable to initialize ODBC connection to DSN

Has anyone got this working?

3 REPLIES 3

Anonymous
Not applicable

@Grainne Farrantโ€‹ :

It is possible to connect QGIS to Databricks using ODBC, but it requires additional configuration. Here are the general steps to follow:

  1. Install the ODBC driver for Databricks on your machine where QGIS is installed. You can download the driver from the Databricks website.
  2. Set up a DSN for Databricks in the ODBC Data Source Administrator on your machine. Make sure you test the connection to ensure it is working properly.
  3. In QGIS, go to the Layer menu and choose Add Layer > Add Vector Layer. Choose the Database tab and click the New button to create a new connection.
  4. Choose the ODBC option and enter the name of the DSN you created in step 2.
  5. Enter your Databricks username and password and click Test Connection to make sure it is working properly.
  6. Once the connection is established, you should be able to see the tables and views available in your Databricks instance and add them to QGIS as layers.

Note that some users have reported issues with using ODBC drivers with QGIS on MacOS, so you may need to use a different approach if you are on that platform.

gfar
New Contributor II

Hello,

I'm on Windows. I have downloaded the driver, set-up the DSN for Databricks and tested it - all works fine. I have used this DSN to connect to Databricks from ArcGIS.

In QGIS, I followed your instructions and when I click test connections, I get an error - Connection failed- check settings and try again. Extended error information: Unable to initialize ODBC connection to DSN for <username>/<password>@<DSN>

I'm using QGIS 3.28.5-Firenze.

lukeoz
New Contributor II

I have been able to connect to Databricks in QGIS using the ODBC connection. An extra step not listed above that I had to do was to generate a personal access token (Databricks user Settings > Developer > Access tokens > Manage > Generate new token).

When setting up the DSN in step 2 above, I used the "User Name and Password" Authentication mechansim, using "token" as the username and the token generated above as the password. SSL has to be enabled in the SSL Options, and the value for Thrift Transport set to HTTP with the HTTP path value (available from the Databricks cluster's Advanced Options JDBC/ODBC tab) set in the HTTP Options

 

Then, once in QGIS, I was able to go to Layer > Add Layer > Add Vector Layer, choose Database, type ODBC, create a new connection, with the value of the Data Source Name when creating the DSN in ODBC DSN Setup used as the value for Database in the Connection information, and for the Authentication configuration, add an authentication configuration, using the same username ("token") and password (personal access token value) from creating the DSN

This all worked for me, and I was successfully able to connect to the database and the tables within them ... 

However, despite the tables I want having fields of "geometry" type, the connector doesn't seem to recognise these fields and be able to draw them in QGIS.

This is where I am currently stuck, if anyone is able to suggest what can be done to display the spatial features from the table stored in Databricks. The geometry features are valid, as I am able to visualise them using SedonaKepler in the local Databricks notebook. In QGIS, the geometry field values appear as "BLOB" in the attribute table and do not seem to be recognised as spatial features.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group