SQL endpooint

A SQL endpoint can be created for querying databricks tables.

Switch the workspace in databricks to SQL, then the 'SQL Endpoints' menu will show.

Create an endpoint and click into the endpoint, the connection details are provided.

The hostname is the instance url, e.g.

   abc-1234567899.azuredatabricks.net

the http path is the api path, e.g. 

   /sql/1.0/endpoints/8d62a904a2ebc35d

Also an access token needs to be generated. This is the same as the REST API's access token.


To program, the databricks sql connection library for python needs to be installed beforehand.

The below script queries a database table and returns results.


%pip install databricks-sql-connector


from databricks import sql


server_hostname = ''

http_path = ''

access_token = ''


with sql.connect(server_hostname,http_path, access_token) as connection:

    with connection.cursor() as cursor:

        cursor.execute("SELECT * FROM <database-name>.<table-name> LIMIT 2")

        result = cursor.fetchall()


        for row in result:

          print(row)