I installed databricks-sql-connector in Pycharm.
Then i run the query below based on docs.
I refer this docs.
(https://docs.databricks.com/dev-tools/python-sql-connector.html)
==========================================
from databricks import sql
import os
with sql.connect(server_hostname = os.getenv("***"),
http_path = os.getenv("***"),
access_token = os.getenv("***")) as connection:
with connection.cursor() as cursor:
cursor.execute("SELECT * FROM default.diamonds LIMIT 2")
result = cursor.fetchall()
for row in result:
print(row)
=================================
However, I faced the error below.
(AttributeError: 'NoneType' object has no attribute 'startswith')
File "C:\Users\MZC01-SSLEE\PycharmProjects\sqlconnector\venv\lib\site-packages\databricks\sql\__init__.py", line 50, in connect
return Connection(server_hostname, http_path, access_token, **kwargs)
File "C:\Users\MZC01-SSLEE\PycharmProjects\sqlconnector\venv\lib\site-packages\databricks\sql\client.py", line 156, in __init__
auth_provider = get_python_sql_connector_auth_provider(
File "C:\Users\MZC01-SSLEE\PycharmProjects\sqlconnector\venv\lib\site-packages\databricks\sql\auth\auth.py", line 84, in get_python_sql_connector_auth_provider
hostname=normalize_host_name(hostname),
File "C:\Users\MZC01-SSLEE\PycharmProjects\sqlconnector\venv\lib\site-packages\databricks\sql\auth\auth.py", line 77, in normalize_host_name
maybe_scheme = "https://" if not hostname.startswith("https://") else ""
AttributeError: 'NoneType' object has no attribute 'startswith'
Could you give me some advice to solve this?