Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2021 08:02 AM
I started to explore Databricks SQL Connector. And I'm wondering can I execute query from Databricks SQL Connector from notebook or job?
sample code:
'test_query' lives in Databricks SQL. It is ready to use query!
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()
Labels: