-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_connection.py
More file actions
27 lines (21 loc) · 784 Bytes
/
test_connection.py
File metadata and controls
27 lines (21 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import configparser
import os
import sys
from snowflake.snowpark import Session
from utils.snowpark_utils import get_snowsql_config
from snowflake.connector.errors import DatabaseError, OperationalError
if __name__ == "__main__":
current_dir = os.getcwd()
parent_dir = os.path.dirname(current_dir)
sys.path.append(parent_dir)
snowpark_config = get_snowsql_config()
snowpark_config['ROLE'] = 'ACCOUNTADMIN'
try:
session = Session.builder.configs(snowpark_config).create()
account = session.get_current_account()
print("Success you're connected to Snowflake account: " + account)
print("Enjoy the Hands-on Lab!")
except OperationalError as oe:
print(oe.msg)
except DatabaseError as de:
print(de.msg)