Skip to content

Instantly share code, notes, and snippets.

@hsuyuming
Created June 8, 2019 06:56
Show Gist options
  • Save hsuyuming/d392e2fee7e4d02c127cf408650c4b22 to your computer and use it in GitHub Desktop.
Save hsuyuming/d392e2fee7e4d02c127cf408650c4b22 to your computer and use it in GitHub Desktop.
#import snowflake connector module
import snowflake.connector
import sys
import os
# 確定輸入的參數是否給定正確
# Sample: python connect_saml.py <account> <user> <role> <warehouse> <database> <schema>
if len(sys.argv) < 7 :
print("ERROR: Please pass the following command-line parameters in order:",end='\n')
print("account,user,role,warehouse,database,schema.")
sys.exit(-1)
else:
ACCOUNT = sys.argv[1]
USER = sys.argv[3]
ROLE = sys.argv[4]
WAREHOUSE = sys.argv[5]
DATABASE = sys.argv[6]
SCHEMA = sys.argv[7]
con = snowflake.connector.connect(
account=ACCOUNT,
user=USER,
authenticator='externalbrowser',
role=ROLE,
warehouse=WAREHOUSE,
database=DATABASE,
schema=SCHEMA
)
results = con.cursor().execute("SELECT * FROM LIBRARY LIMIT 1")
for result in results:
print(result[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment