Anonymous
Not applicable

@Hanna Wade​ : Yes, it is possible to run Databricks queries from VBA by using the Databricks REST API. To run a Databricks query from VBA, you would need to use VBA's HTTP request library to send a POST request to the Databricks REST API endpoint that executes the query. You would also need to authenticate with Databricks using an access token or personal access token.

Sub RunDatabricksQuery()
 
    Dim apiUrl As String
    Dim accessToken As String
    Dim requestBody As String
    Dim http As New XMLHTTP60
    Dim responseText As String
    
    ' Set the Databricks API URL and access token
    apiUrl = "https://<databricks-instance>/api/2.0/sql/endpoints/<endpoint-id>/query"
    accessToken = "<access-token>"
    
    ' Set the query to be executed
    requestBody = "{""query"":""SELECT * FROM my_table""}"
    
    ' Send the POST request to execute the query
    http.Open "POST", apiUrl, False
    http.setRequestHeader "Authorization", "Bearer " & accessToken
    http.setRequestHeader "Content-Type", "application/json"
    http.send requestBody
    
    ' Retrieve the query results
    responseText = http.responseText
    
    ' Do something with the query results
    Debug.Print responseText
    
End Sub

Please refer the link: https://docs.databricks.com/dev-tools/api/index.html

View solution in original post