forked from databricks/databricks-sql-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.py
More file actions
42 lines (31 loc) · 989 Bytes
/
Copy pathcheck.py
File metadata and controls
42 lines (31 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import sys
# import logging
#
# logging.basicConfig(level=logging.DEBUG)
#
# # Get the parent directory of the current file
# target_folder_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "databricks-sql-python", "src"))
#
# # Add the parent directory to sys.path
# sys.path.append(target_folder_path)
from databricks import sql
# from dotenv import load_dotenv
# export DATABRICKS_TOKEN=whatever
# Load environment variables from .env file
# load_dotenv()
host = os.getenv("MY_SERVER_HOSTNAME")
http_path = os.getenv("MY_HTTP_PATH")
access_token = os.getenv("MY_TOKEN")
connection = sql.connect(
server_hostname=host,
http_path=http_path,
access_token=access_token)
cursor = connection.cursor()
cursor.execute("select * from `auto_maintenance_bugbash`.`tpcds_sf1000_naga_testv32`.`store_sales` LIMIT 1000")
# cursor.execute('SELECT 1')
result = cursor.fetchmany(10)
for row in result:
print(row)
cursor.close()
connection.close()