from .const import DB_URL_RE as DB_URL_RE, DOMAIN as DOMAIN
from .models import SQLData as SQLData
from _typeshed import Incomplete
from homeassistant.components.recorder import SupportedDialect as SupportedDialect, get_instance as get_instance
from homeassistant.const import EVENT_HOMEASSISTANT_STOP as EVENT_HOMEASSISTANT_STOP
from homeassistant.core import Event as Event, HomeAssistant as HomeAssistant, callback as callback
from homeassistant.exceptions import HomeAssistantError as HomeAssistantError, TemplateError as TemplateError
from homeassistant.helpers.template import Template as Template
from sqlalchemy.orm import Session as Session, scoped_session
from sqlalchemy.sql.lambdas import StatementLambdaElement as StatementLambdaElement
from sqlalchemy.util import LRUCache
from typing import Any

_LOGGER: Incomplete
_SQL_LAMBDA_CACHE: LRUCache

def redact_credentials(data: str | None) -> str: ...
def resolve_db_url(hass: HomeAssistant, db_url: str | None) -> str: ...
def validate_sql_select(value: Template) -> Template: ...
async def async_create_sessionmaker(hass: HomeAssistant, db_url: str) -> tuple[scoped_session | None, bool, bool]: ...
def validate_query(hass: HomeAssistant, query_template: str | Template, uses_recorder_db: bool, unique_id: str | None = None) -> None: ...
@callback
def _async_get_or_init_domain_data(hass: HomeAssistant) -> SQLData: ...
def _validate_and_get_session_maker_for_db_url(db_url: str) -> scoped_session | None: ...
def generate_lambda_stmt(query: str) -> StatementLambdaElement: ...
def convert_value(value: Any) -> Any: ...
def check_and_render_sql_query(hass: HomeAssistant, query: Template | str) -> str: ...

class InvalidSqlQuery(HomeAssistantError): ...
class EmptyQueryError(InvalidSqlQuery): ...
class MultipleQueryError(InvalidSqlQuery): ...
class UnknownQueryTypeError(InvalidSqlQuery): ...
class NotSelectQueryError(InvalidSqlQuery): ...
