Skip to main content

BaseSQLHandler

Class
📁application_sdk.handlers.sql
Inheritance chain:
HandlerInterface

A concrete implementation of HandlerInterface specifically designed for interacting with SQL-based data sources. Uses SQLClient for database communication and provides SQL query-driven behavior with configurable SQL queries for common operations.

Methods5

__init__

__init__(self, sql_client)
Initialize the handler with a required SQLClient instance
Parameters
sql_clientSQLClient
Required
SQL client instance for database communication

load

async
async load(self, credentials)
Calls load() on the provided SQL client with the given credentials
Parameters
credentialsdict
Required
Database authentication credentials

test_auth

async
async test_auth(self, **kwargs) -> bool
Executes test_authentication_sql query using SQLQueryInput to test database connectivity
Parameters
kwargsdict
Required
Keyword arguments (typically empty for basic auth test)
Returns
bool - True if authentication succeeds, False otherwise

preflight_check

async
async preflight_check(self, payload, **kwargs) -> dict
Orchestrates several checks: check_schemas_and_databases() (validates include/exclude filters), tables_check() (counts tables using tables_check_sql), and check_client_version() (verifies against SQL_SERVER_MIN_VERSION)
Parameters
payloaddict
Required
Payload containing configuration and filters
kwargsdict
Optional
Additional keyword arguments
Returns
dict - Dictionary with check results and overall success status

fetch_metadata

async
async fetch_metadata(self, **kwargs) -> Any
Based on metadata_type argument, calls prepare_metadata() (executes metadata_sql), fetch_databases() (executes fetch_databases_sql), or fetch_schemas() (executes fetch_schemas_sql)
Parameters
kwargsdict
Required
Keyword arguments including metadata_type and filters
Returns
Any - Metadata based on the requested type

Usage Examples

Basic SQL Handler Usage

Create a BaseSQLHandler with a specific SQL client for database operations

from application_sdk.handlers.sql import BaseSQLHandler
from .clients import PostgreSQLClient

# Initialize with specific SQL client
client = PostgreSQLClient()
handler = BaseSQLHandler(sql_client=client)

# Use with Application
from application_sdk.server.fastapi import APIServer
app = APIServer(handler=handler)