Python
If you have custom Python code using the Databricks SQL Connector for Python, change server_hostname to the Espresso AI hostname and leave http_path unchanged, e.g.
from databricks import sql
with sql.connect(
server_hostname="<workspace>.cloud.databricks.espressocomputing.com",
http_path="/sql/1.0/warehouses/<warehouse_id>",
access_token="<personal_access_token>",
) as connection:
with connection.cursor() as cursor:
cursor.execute("SELECT 1")
print(cursor.fetchall())OAuth for service principals (M2M)
With OAuth M2M, only the SQL connection needs the Espresso AI hostname. The credential provider can keep pointing at your Databricks workspace URL:
from databricks.sdk.core import Config, oauth_service_principal
from databricks import sql
def credential_provider():
config = Config(
host="https://<workspace>.cloud.databricks.com",
client_id="<client_id>",
client_secret="<client_secret>",
)
return oauth_service_principal(config)
with sql.connect(
server_hostname="<workspace>.cloud.databricks.espressocomputing.com",
http_path="/sql/1.0/warehouses/<warehouse_id>",
credentials_provider=credential_provider,
) as connection:
# ...OAuth for users (U2M)
Last updated