cannot import name 'sql' from 'databricks'

mickniz
Contributor

I am working on Databricks version 10.4 premium cluster and while importing sql from databricks module I am getting below error.

cannot import name 'sql' from 'databricks' (/databricks/python/lib/python3.8/site-packages/databricks/__init__.py).Trying to execute below sample code

from databricks import sql

import os

with sql.connect(server_hostname = os.getenv("DATABRICKS_SERVER_HOSTNAME"),

         http_path    = os.getenv("DATABRICKS_HTTP_PATH"),

         access_token  = os.getenv("DATABRICKS_TOKEN")) as connection:

 with connection.cursor() as cursor:

  cursor.execute("SELECT * FROM default.x LIMIT 2")

  result = cursor.fetchall()

  for row in result:

   print(row)

ANy suggestion here