11-29-2021 04:00 AM
Hello. I'm trying to connect to Databricks from my IDE (PyCharm) and then run delta table queries from there. However, the cluster I'm trying to access has to give me permission. In this case, I'd go to my cluster, run the cell which gives me permission and then go back to my PyCharm so I can query the tables. The question I'm trying to ask here is, is there some way to do this kind of configuration from PyCharm directly? This is the code I use to give permission
if StorageAccountName is not None and StorageAccountAccessKey is not None:
print('Configuring the spark context...')
spark_context._jsc.hadoopConfiguration().set(
f"fs.azure.account.key.{StorageAccountName}.blob.core.windows.net",
StorageAccountAccessKey)
I use it this way, and not directly as a Spark configuration, because my StorageAccountAccessKey is stored in key-vault and a cluster might have info from various storage accounts which means I'd have various access keys, etc.
11-29-2021 04:13 AM
"I'm trying to connect to Databricks from my IDE (PyCharm) and then run delta table queries from there."
If you are going to deploy later your code to databricks the only solutions which I see is to use databricks-connect or just make development environment in cloud and work there (and use repos for pull requests to production).
If your code will not be deployed to databricks and you want just to query table from somewhere else you can use just JDBC/ODBC connector. If you want to make cluster and different administrator operations you can install databricks-cli and than extend it inside your code something like below example:
from databricks_cli.sdk import ApiClient
from databricks_cli.sdk import service
host = "your_host"
token = "your_token"
client = ApiClient(host=host, token=token)
workspace = service.WorkspaceService(client)
11-29-2021 04:04 AM
Are you using databricks-connect ?
11-29-2021 04:07 AM
For some bad reason, I can't use databricks-connect. I get module java.base does not "opens java.nio" to unnamed module error and I can't solve it nor I know what it is. For now, I use python-sql-connector (https://docs.databricks.com/dev-tools/python-sql-connector.html)
11-29-2021 04:13 AM
"I'm trying to connect to Databricks from my IDE (PyCharm) and then run delta table queries from there."
If you are going to deploy later your code to databricks the only solutions which I see is to use databricks-connect or just make development environment in cloud and work there (and use repos for pull requests to production).
If your code will not be deployed to databricks and you want just to query table from somewhere else you can use just JDBC/ODBC connector. If you want to make cluster and different administrator operations you can install databricks-cli and than extend it inside your code something like below example:
from databricks_cli.sdk import ApiClient
from databricks_cli.sdk import service
host = "your_host"
token = "your_token"
client = ApiClient(host=host, token=token)
workspace = service.WorkspaceService(client)
11-29-2021 04:17 AM
So you suggest to go with databricks-connect, I see. Do you have any ideas what could cause the error explained in my previous comment and how could I fix it?
11-29-2021 04:26 AM
------------------------------------------------------------------------------
Databricks Runtime version >> Python version
------------------------------------------------------------------------------
9.1 LTS ML, 9.1 LTS >> 3.8
7.3 LTS ML, 7.3 LTS >> 3.7
6.4 ML, 6.4 >> 3.7
5.5 LTS ML >> 3.6
5.5 LTS >> 3.5
------------------------------------------------------------------------------
currently only above runtimes are supported
more here https://docs.databricks.com/dev-tools/databricks-connect.html
11-29-2021 04:50 AM
Thanks! I downgraded to Java 8 and it works now. I must have the winutils from hadoop added as env var, right? Without it, if I delete it let's say, it won't work?
11-29-2021 05:34 AM
yes it is necessary and path to folder have to be added PATH=%PATH%;%HADOOP_PREFIX%\bin
Any chance to be selected as the best answer? 🙂
11-29-2021 05:35 AM
Sure 🙂
11-29-2021 10:39 AM
Hi @Martin Kostadinov ,
Did you check the troubleshooting section from DBconnect docs? did this help you to find the response to your issue? docs here https://docs.databricks.com/dev-tools/databricks-connect.html#troubleshooting
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