from databricks import sql
hostname = '<name>.databricks.com'
http_path = '/sql/1.0/endpoints/<endpoint_id>'
access_token = '<personal_token>'
connection = sql.connect(server_hostname=hostname, http_path=http_path, access_token=access_token)
cursor = connection.cursor()
cursor.execute('test_query')
result = cursor.fetchall()
for row in result:
print(row)
cursor.close()
I get the following error when I execute the code above in notebook.
I have permissions for the entrypoint that I use and access_token. I have removed them in the question!
Error during OpenSession; Request: TOpenSessionReq(client_protocol=5, username=None, password=None, configuration=None) Error: None Bounded-Retry-Delay: None Attempt: 1/30 Elapsed-Seconds: 1.3954582214355469/900.0
----> 7 connection = sql.connect(server_hostname=hostname,
8 http_path=http_path,
9 access_token=access_token)
/databricks/python/lib/python3.8/site-packages/databricks/sql/__init__.py in connect(server_hostname, http_path, access_token, **kwargs)
26 """
27 from databricks.sql.client import Connection
---> 28 return Connection(server_hostname, http_path, access_token, **kwargs)
/databricks/python/lib/python3.8/site-packages/databricks/sql/client.py in __init__(self, server_hostname, http_path, access_token, **kwargs)
261 client_protocol=protocol_version
262 )
--> 263 response = self._make_request(self._client.OpenSession, open_session_req)
264 _check_status(response)
265 assert response.sessionHandle is not None, "Expected a session from OpenSession"
/databricks/python/lib/python3.8/site-packages/databricks/sql/client.py in _make_request(self, method, request)
372 or elapsed + retry_delay > self._retry_stop_after_attempts_duration):
373 _logger.error("Error during " + log_base)
--> 374 raise OperationalError("Error during Thrift request" +
375 (": " + error_message) if error_message else "",
376 error)
OperationalError: ('', EOFError())