-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnowflake.py
More file actions
36 lines (27 loc) · 986 Bytes
/
Copy pathsnowflake.py
File metadata and controls
36 lines (27 loc) · 986 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
import snowflake
QUERY_TO_VALIDATE_SNOWFLAKE_DATA_DETAILS = "select count(*) from INFORMATION_SCHEMA.columns where table_name = {}" \
" and column_name = {}"
def get_snowflake_connection():
ctx = snowflake.connector.connect(
user="abhilash2121",
password="Fazer@12345",
account="ljb39130.us-east-1",
database="SNOWFLAKE"
)
conn = ctx.cursor(DictCursor)
return conn
"""
def check_schema(schema, conn):
schemas = conn.execute("show schemas").fetchall()
print(schemas)
schema_list = [item["name"] for item in schemas]
if schema in schema_list:
return True
else:
return False
"""
conn = get_snowflake_connection()
res = conn.execute("select * from INFORMATION_SCHEMA.tables")
results = res.fetchall()
schema_list = [item["TABLE_SCHEMA"] for item in results]
table_list = [item["TABLE_NAME"] for item in results if item["TABLE_SCHEMA"] == "ACCOUNT_USAGE"]