class_docstr: A connection to Snowflake using the Snowflake Python Connector. Initialize using
  ``st.connection("<name>", type="snowflake")``.
  
  SnowflakeConnection supports direct SQL querying using ``.query("...")``, access to
  the underlying Snowflake Python Connector object with ``.raw_connection``, and other
  convenience functions. See the methods below for more information.
  SnowflakeConnections should always be created using ``st.connection()``, **not**
  initialized directly.
code: def _connect(self, **kwargs) -> "InternalSnowflakeConnection":
      import snowflake.connector  # type:ignore[import]
      from snowflake.connector import (
          Error as SnowflakeError,
      )  # type:ignore[import]
  
      # If we're running in SiS, just call get_active_session() and retrieve the
      # lower-level connection from it.
      if running_in_sis():
          from snowflake.snowpark.context import (  # type:ignore[import]  # isort: skip
              get_active_session,
          )
  
          session = get_active_session()
  
          if hasattr(session, "connection"):
              return session.connection
          # session.connection is only a valid attr in more recent versions of
          # snowflake-connector-python, so we fall back to grabbing
          # session._conn._conn if `.connection` is unavailable.
          return session._conn._conn
  
      # We require qmark-style parameters everywhere for consistency across different
      # environments where SnowflakeConnections may be used.
      snowflake.connector.paramstyle = "qmark"
  
      # Otherwise, attempt to create a new connection from whatever credentials we
      # have available.
      try:
          st_secrets = self._secrets.to_dict()
          if len(st_secrets):
              conn_kwargs = {**st_secrets, **kwargs}
              return snowflake.connector.connect(**conn_kwargs)
  
          # session.connector.connection.CONFIG_MANAGER is only available in more recent
          # versions of snowflake-connector-python.
          if hasattr(snowflake.connector.connection, "CONFIG_MANAGER"):
              config_mgr = snowflake.connector.connection.CONFIG_MANAGER
  
              default_connection_name = "default"
              try:
                  default_connection_name = config_mgr[
                      "default_connection_name"
                  ]
              except snowflake.connector.errors.ConfigSourceError:
                  # Similarly, config_mgr["default_connection_name"] only exists in even
                  # later versions of recent versions. if it doesn't, we just use
                  # "default" as the default connection name.
                  pass
  
              connection_name = (
                  default_connection_name
                  if self._connection_name == "snowflake"
                  else self._connection_name
              )
              return snowflake.connector.connect(
                  connection_name=connection_name,
                  **kwargs,
              )
  
          return snowflake.connector.connect(**kwargs)
      except SnowflakeError as e:
          if not len(st_secrets) and not len(kwargs):
              raise StreamlitAPIException(
                  "Missing Snowflake connection configuration. "
                  "Did you forget to set this in `secrets.toml`, a Snowflake configuration file, "
                  "or as kwargs to `st.connection`? "
                  "See the [SnowflakeConnection configuration documentation](https://docs.streamlit.io/st.connections.snowflakeconnection-configuration) "
                  "for more details and examples."
              )
          raise e
  
file_path: streamlit/lib/streamlit/connections/snowflake_connection.py
imports: from __future__ import annotations
  from datetime import timedelta
  from typing import TYPE_CHECKING, cast
  import pandas
  from streamlit.connections import BaseConnection
  from streamlit.connections.util import running_in_sis
  from streamlit.errors import StreamlitAPIException
  from streamlit.runtime.caching import cache_data
label_desc: Use image node_id 1 for calling the SnowflakeConnection obj's underlying member method code with example usage: obj._connect() and returns: session, snowflake, session, snowflake, snowflake