from typing import Any, Optional

import clickhouse_connect


class ClickHouseClient:
    def __init__(
        self,
        host: str,
        port: int = 8123,
        username: str = "default",
        password: str = "",
        database: str = "default",
        secure: bool = False,
    ):
        self.client = clickhouse_connect.get_client(
            host=host,
            port=port,
            username=username,
            password=password,
            database=database,
            secure=secure,
        )

    def query(self, sql: str, parameters: Optional[dict[str, Any]] = None):
        return self.client.query(sql, parameters=parameters)

    def command(self, sql: str, parameters: Optional[dict[str, Any]] = None):
        return self.client.command(sql, parameters=parameters)
