Executing Queries
Execute SQL queries against Komodo’s Snowflake data warehouse using standard DB-API 2.0 patterns.
Get a Connection
Section titled “Get a Connection”The get_snowflake_connection() function returns a DB-API 2.0 compliant connection:
from komodo import get_snowflake_connection
conn = get_snowflake_connection()Execute Queries
Section titled “Execute Queries”Use cursors to execute queries:
cursor = conn.cursor()
# Execute a querycursor.execute("USE DATABASE DATA")cursor.execute("SELECT column_name, table_name FROM INFORMATION_SCHEMA.COLUMNS LIMIT 20")
# Fetch resultsrows = cursor.fetchall()print(f"Found {len(rows)} columns")
cursor.close()conn.close()Fetching Results
Section titled “Fetching Results”Fetch All Rows
Section titled “Fetch All Rows”cursor.execute("SELECT * FROM INFORMATION_SCHEMA.COLUMNS")all_rows = cursor.fetchall()Fetch One Row
Section titled “Fetch One Row”cursor.execute("SELECT * FROM INFORMATION_SCHEMA.COLUMNS LIMIT 1")row = cursor.fetchone()print(row)Fetch Multiple Rows
Section titled “Fetch Multiple Rows”cursor.execute("SELECT * FROM INFORMATION_SCHEMA.COLUMNS LIMIT 100")# Fetch 10 rows at a timebatch = cursor.fetchmany(size=10)