SDK Reference
Client
Section titled “Client”Low-level access to the Komodo Platform HTTP APIs (IAM, etc.). get_snowflake_connection() constructs a Client internally; use Client directly when you need client.iam or other generated API wrappers.
Import
Section titled “Import”from komodo import ClientConstructor
Section titled “Constructor”def __init__( self, account_id: str | None = None, auth_session: Session | None = None, **kwargs,) -> Noneaccount_id— Komodo account UUID. If omitted, taken from the session / credentials when available.auth_session— Optional KomodoSession(komodo.auth.Session). If omitted, a defaultSession()is created andconnect()is called.
Notable members
Section titled “Notable members”| Member | Description |
|---|---|
auth | Active Session (tokens, refresh). |
iam | Generated IAM API client (IamApi). |
x_account_id | Resolved account ID for API calls. |
komodo_api_client() | Underlying OpenAPI ApiClient. |
Async context manager
Section titled “Async context manager”classmethod async def create(...) -> Clientasync def close()async def __aenter__ / __aexit__Use async with await Client.create(...) as client: when you need explicit cleanup of the HTTP session.
get_snowflake_connection
Section titled “get_snowflake_connection”Returns a DB-API 2.0 Connection to your account’s Snowflake warehouse (Komodo connector), with query tags applied for observability.
Import
Section titled “Import”from komodo import get_snowflake_connectionSignature
Section titled “Signature”def get_snowflake_connection( account_id: str | None = None, jwt: str | None = None, client_id: str | None = None, client_secret: str | None = None, profile: str | None = None,) -> ConnectionParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
account_id | str | None | Komodo account UUID. Required unless the session / profile supplies it. Cannot be combined with profile if the profile already defines an account. |
jwt | str | None | Bearer token for user-style auth. Cannot be combined with client_id / client_secret. |
client_id | str | None | Service principal client ID (M2M). Must be used with client_secret and account_id (unless profile supplies them). |
client_secret | str | None | Service principal secret (M2M). |
profile | str | None | Named section in the credentials file (M2M + account). Mutually exclusive with passing jwt or split client_id/client_secret in the same call. |
Returns
Section titled “Returns”Connection — DB-API 2.0 connection (Komodo Snowflake proxy). Use conn.cursor() to obtain a KomodoSnowflakeCursor.
Raises
Section titled “Raises”| Exception | When |
|---|---|
ValueError | Invalid combination of arguments (e.g. JWT + client secret, or profile with explicit creds). |
UnsetAccountError | No account_id and none could be resolved from the session / file. |
Example
Section titled “Example”from komodo import get_snowflake_connection
conn = get_snowflake_connection()cur = conn.cursor()cur.execute("SELECT 1")print(cur.fetchone())conn.close()execute_query_async
Section titled “execute_query_async”Async helper: execute_async on the cursor, poll until the query finishes, then attach results to the cursor and return that cursor.
Import
Section titled “Import”from komodo import execute_query_asyncSignature
Section titled “Signature”async def execute_query_async( cursor: KomodoSnowflakeCursor, query: str, query_params: list[str] | dict[str, str] | None = None,) -> KomodoSnowflakeCursorParameters
Section titled “Parameters”| Name | Description |
|---|---|
cursor | Open cursor from get_snowflake_connection().cursor(). |
query | SQL string. |
query_params | Optional bind parameters for the connector. |
Returns
Section titled “Returns”The same cursor after results are loaded — call fetchall(), fetch_pandas_all(), etc.
Example
Section titled “Example”import asynciofrom komodo import get_snowflake_connection, execute_query_async
async def main(): conn = get_snowflake_connection() cur = conn.cursor() cur = await execute_query_async(cur, "SELECT CURRENT_TIMESTAMP()") print(cur.fetchone()) conn.close()
asyncio.run(main())is_still_running
Section titled “is_still_running”def is_still_running(map_connection: Connection, query_id: str) -> boolReturns whether a given Snowflake query id is still running. Used internally by execute_query_async; may raise SnowflakeException if status checks fail.
Snowflake-related exceptions
Section titled “Snowflake-related exceptions”| Name | Module | Description |
|---|---|---|
UnsetAccountError | komodo.snowflake | Missing account context when opening a connection. |
SnowflakeException | komodo.snowflake | Wrapped errors around query status / Map connector operations. |
from komodo.snowflake import UnsetAccountError, SnowflakeExceptionUnsetAccountError is also available from the top-level komodo package (from komodo import UnsetAccountError).
OpenAPI / REST exceptions
Section titled “OpenAPI / REST exceptions”Generated clients raise subclasses of OpenApiException (for example ApiException, ApiValueError). Import from komodo:
from komodo import ApiException, ApiValueError, OpenApiExceptionCursor operations
Section titled “Cursor operations”After cursor = conn.cursor():
| Method / attribute | Typical use |
|---|---|
execute(sql, params=None) | Run SQL. |
fetchone, fetchmany, fetchall | DB-API results. |
fetch_pandas_all, fetch_pandas_batches | Pandas DataFrames (Snowflake cursor). |
execute_async, get_results_from_sfqid | Advanced / used by execute_query_async. |
description | Column metadata after a select. |
For SQL and CLI patterns, see Executing Queries and Pandas Integration.