Skip to content

BaseConnection

relationalai.config.connections.base

Base class for connection configuration objects.

Subclasses define the connection-specific fields and implement BaseConnection.get_session to create the underlying client/session object (Snowpark, DuckDB, requests, etc.). The session is cached on the instance; call BaseConnection.clear_session_cache to force a fresh session on the next access.

Subclasses must define a type field as a typing.Literal for Pydantic discriminated unions.

BaseConnection.get_session() -> Any

Return the underlying session/client for this connection.

Override this in subclasses to create the connection-specific session (for example, a Snowpark session, DuckDB connection, or Session).

Returns:

  • Any - The connection-specific session/client object.

Raises:

BaseConnection.clear_session_cache() -> None

Clear any cached session for this connection.

After calling this, the next call to BaseConnection.get_session creates a fresh session/client.

BaseConnectionpydantic.BaseModelabc.ABC
 config > connections
├──  duckdb
│   └──  DuckDBConnection
├──  local
│   └──  LocalConnection
└──  snowflake
    ├──  ExternalBrowserAuth
    ├──  JWTAuth
    ├──  OAuthAuth
    ├──  ProgrammaticAccessTokenAuth
    ├──  SnowflakeConnectionBase
    ├──  UsernamePasswordAuth
    └──  UsernamePasswordMFAAuth
RelationalAI Documentation
└──  Build With RelationalAI
    └──  Understand how PyRel works > Configure PyRel
        ├──  Overview
        │   └──  How database sessions are managed
        └──  Configure snowflake auth
            └──  Clear the session cache to create a fresh session