Salesforce

Using Single Sign On (SSO) with Python using Jupyter Notebook

« Go Back

Information

 
SummaryThis code snippet would help you to execute your first Snowflake SQL statement using python in Jupyter Notebook
Last Modified DateJanuary 12, 2023
Solution

Pre-requisite:
In order to use setup Snowflake with Jupyter Notebook, please refer to this article: Connecting Jupyter Notebook with Snowflake
You need to have a successful & working SSO configuration setup with your choice of Identity Provider

import snowflake.connector
import sys
con = snowflake.connector.connect(
    user="<login_name>", #You can get it by executing in UI: desc user <username>;
    account="<account-name>", #Add all of the account-name between https:// and snowflakecomputing.com
    authenticator="externalbrowser",
)
cur = con.cursor()
print(sys.executable)
print(sys.version)
print(sys.version_info)
try:
    cur.execute("select current_date")
    one_row=cur.fetchone()
    print("Current_Date:",one_row[0])
    cur.execute("SELECT current_version()")
    one_row = cur.fetchone()
    print("Snowfalke_Version:",one_row[0])
finally:
    cur.close()
cur.close()


Example Output:

User-added image

Additional Information
URL NameUsing-Single-Sign-On-SSO-with-Python-using-Jupyter-Notebook
TitleUsing Single Sign On (SSO) with Python using Jupyter Notebook
CategoryManaging Security & Authentication
Sub CategoryFederated Authentication & SSO
Article Record TypeFAQ

Powered by