Skip to content

SDK Reference

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.

from komodo import Client
def __init__(
self,
account_id: str | None = None,
auth_session: Session | None = None,
**kwargs,
) -> None
  • account_id — Komodo account UUID. If omitted, taken from the session / credentials when available.
  • auth_session — Optional Komodo Session (komodo.auth.Session). If omitted, a default Session() is created and connect() is called.
MemberDescription
authActive Session (tokens, refresh).
iamGenerated IAM API client (IamApi).
x_account_idResolved account ID for API calls.
komodo_api_client()Underlying OpenAPI ApiClient.
classmethod async def create(...) -> Client
async def close()
async def __aenter__ / __aexit__

Use async with await Client.create(...) as client: when you need explicit cleanup of the HTTP session.


Returns a DB-API 2.0 Connection to your account’s Snowflake warehouse (Komodo connector), with query tags applied for observability.

from komodo import get_snowflake_connection
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,
) -> Connection
NameTypeDescription
account_idstr | NoneKomodo account UUID. Required unless the session / profile supplies it. Cannot be combined with profile if the profile already defines an account.
jwtstr | NoneBearer token for user-style auth. Cannot be combined with client_id / client_secret.
client_idstr | NoneService principal client ID (M2M). Must be used with client_secret and account_id (unless profile supplies them).
client_secretstr | NoneService principal secret (M2M).
profilestr | NoneNamed section in the credentials file (M2M + account). Mutually exclusive with passing jwt or split client_id/client_secret in the same call.

Connection — DB-API 2.0 connection (Komodo Snowflake proxy). Use conn.cursor() to obtain a KomodoSnowflakeCursor.

ExceptionWhen
ValueErrorInvalid combination of arguments (e.g. JWT + client secret, or profile with explicit creds).
UnsetAccountErrorNo account_id and none could be resolved from the session / file.
from komodo import get_snowflake_connection
conn = get_snowflake_connection()
cur = conn.cursor()
cur.execute("SELECT 1")
print(cur.fetchone())
conn.close()

Async helper: execute_async on the cursor, poll until the query finishes, then attach results to the cursor and return that cursor.

from komodo import execute_query_async
async def execute_query_async(
cursor: KomodoSnowflakeCursor,
query: str,
query_params: list[str] | dict[str, str] | None = None,
) -> KomodoSnowflakeCursor
NameDescription
cursorOpen cursor from get_snowflake_connection().cursor().
querySQL string.
query_paramsOptional bind parameters for the connector.

The same cursor after results are loaded — call fetchall(), fetch_pandas_all(), etc.

import asyncio
from 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())

def is_still_running(map_connection: Connection, query_id: str) -> bool

Returns whether a given Snowflake query id is still running. Used internally by execute_query_async; may raise SnowflakeException if status checks fail.


NameModuleDescription
UnsetAccountErrorkomodo.snowflakeMissing account context when opening a connection.
SnowflakeExceptionkomodo.snowflakeWrapped errors around query status / Map connector operations.
from komodo.snowflake import UnsetAccountError, SnowflakeException

UnsetAccountError is also available from the top-level komodo package (from komodo import UnsetAccountError).


Generated clients raise subclasses of OpenApiException (for example ApiException, ApiValueError). Import from komodo:

from komodo import ApiException, ApiValueError, OpenApiException

After cursor = conn.cursor():

Method / attributeTypical use
execute(sql, params=None)Run SQL.
fetchone, fetchmany, fetchallDB-API results.
fetch_pandas_all, fetch_pandas_batchesPandas DataFrames (Snowflake cursor).
execute_async, get_results_from_sfqidAdvanced / used by execute_query_async.
descriptionColumn metadata after a select.

For SQL and CLI patterns, see Executing Queries and Pandas Integration.