Created
June 18, 2025 04:02
-
-
Save swateek/8b9238a1ebd55ff8eae9c019995864f2 to your computer and use it in GitHub Desktop.
DataBricks SQL WareHouse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from databricks import sql | |
DATABRICKS_USE2_PAT = "" | |
use2_workspace = sql.connect( | |
server_hostname="<YOUR-SERVER-HOSTNAME>", | |
http_path="<YOUR-HTTP-PATH>", | |
access_token=DATABRICKS_USE2_PAT, | |
catalog="<YOUR-CATALOG-NAME>", | |
schema="<YOUR-SCHEMA-NAME>" | |
) | |
cursor = use2_workspace.cursor() | |
# cursor.execute("SELECT * from range(10)") | |
cursor.execute("SELECT COUNT(*) FROM view_transactions;") | |
print(cursor.fetchall()) | |
cursor.close() | |
use2_workspace.close() | |
# catalog & schema are optional parameters in sql.connect() | |
# if not provided in connection, then the query must be written as below | |
# SELECT COUNT(*) FROM `catalog`.`schema`.view_transactions; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment