-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnowflake_reader.py
More file actions
35 lines (30 loc) · 837 Bytes
/
snowflake_reader.py
File metadata and controls
35 lines (30 loc) · 837 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
import snowflake.connector
import configparser
# Load config
config = configparser.ConfigParser()
config.read('config.ini')
sf_config = config['Snowflake']
# Connect using host
conn = snowflake.connector.connect(
user=sf_config['user'],
password=sf_config['password'],
account=sf_config['account'],
host=sf_config['host'],
warehouse=sf_config['warehouse'],
database=sf_config['database'],
schema=sf_config['schema'],
protocol='https',
ocsp_fail_open=True # helpful in private network setups
)
try:
cursor = conn.cursor()
query = f'''
SELECT *
FROM {sf_config['database']}.{sf_config['schema']}.{sf_config['table']}
'''
cursor.execute(query)
for row in cursor.fetchall():
print(row)
finally:
cursor.close()
conn.close()