Skip to main content

snippets_py

Integration

New integration from credential
snowflake_connection = yepcode.integration.snowflake('credential-slug')
New integration from plain authentication data
from snowflake.connector import connect

snowflake_connection = connect(
user="username",
password="password",
# You should use a yepcode env variable to don't store plain password
# See: https://docs.yepcode.io/docs/processes/team-variables
account="account",
database="database",
schema="schema",
)

Execute Statement

Execute statement
cursor = snowflake_connection.cursor()

cursor.execute("SELECT * FROM sales_stock WHERE COLOR_ID = 38379663 LIMIT 10;")

for item in cursor:
print(item)

Execute Statement with Parameters

Execute statement with parameters (literals)
cursor = snowflake_connection.cursor()

cursor.execute(
"SELECT * FROM sales_stock WHERE COLOR_ID = %s LIMIT 10;", (
"38379663"
)
)

for item in cursor:
print(item)

Execute Statement with Parameters

Execute statement with parameters (bind variables)
cursor = snowflake_connection.cursor()

cursor.execute(
"SELECT * FROM sales_stock WHERE COLOR_ID = %(color_id)s LIMIT 10", {
"color_id": 38379663,
}
)


for item in cursor:
print(item)

Insert Statement

Insert statement
cursor = snowflake_connection.cursor()

cursor.execute(
'INSERT INTO yourtable("Name","Number") VALUES(%s,%d)', (
'some-name',
4023
)
)

Select Statement

Select statement
cursor = snowflake_connection.cursor()

cursor.execute("SELECT * FROM sales_stock WHERE COLOR_ID = 38379663 LIMIT 10;")

for item in cursor:
print(item)

Destroy Connection

Terminating a connection
snowflake_connection.close()