From 81091c726492e37dd5b1dde58acae1c1936dba28 Mon Sep 17 00:00:00 2001 From: Marcel Coetzee Date: Tue, 12 Mar 2024 16:52:02 +0200 Subject: [PATCH] Wireframe ClickhouseSqlClient #1055 Signed-off-by: Marcel Coetzee --- .../impl/clickhouse/sql_client.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/dlt/destinations/impl/clickhouse/sql_client.py b/dlt/destinations/impl/clickhouse/sql_client.py index e69de29bb2..6636da385d 100644 --- a/dlt/destinations/impl/clickhouse/sql_client.py +++ b/dlt/destinations/impl/clickhouse/sql_client.py @@ -0,0 +1,50 @@ +from typing import AnyStr, Any, ContextManager, Optional, Sequence + +import clickhouse_driver +from clickhouse_driver.dbapi.extras import DictCursor + +from dlt.destinations.sql_client import DBApiCursorImpl, SqlClientBase +from dlt.destinations.typing import DBTransaction, DBApiCursor, TNativeConn + + +class ClickhouseDBApiCursorImpl(DBApiCursorImpl): + native_cursor: DictCursor + + +class ClickhouseSqlClient(SqlClientBase[clickhouse_driver.Client], DBTransaction): + def open_connection(self) -> TNativeConn: + pass + + def close_connection(self) -> None: + pass + + def begin_transaction(self) -> ContextManager[DBTransaction]: + pass + + @property + def native_connection(self) -> TNativeConn: + pass + + def execute_sql( + self, sql: AnyStr, *args: Any, **kwargs: Any + ) -> Optional[Sequence[Sequence[Any]]]: + pass + + def execute_query( + self, query: AnyStr, *args: Any, **kwargs: Any + ) -> ContextManager[DBApiCursor]: + pass + + def fully_qualified_dataset_name(self, escape: bool = True) -> str: + pass + + @staticmethod + def _make_database_exception(ex: Exception) -> Exception: + pass + + +class TransactionsNotImplementedError(NotImplementedError): + def __init__(self) -> None: + super().__init__( + "Clickhouse does not support transaction management." + )