From dce1967f3d32cc7e52a619cd17d19cba55ab67b8 Mon Sep 17 00:00:00 2001 From: Marcel Coetzee Date: Thu, 11 Apr 2024 20:43:01 +0200 Subject: [PATCH] Remove empty dataset default #1055 Signed-off-by: Marcel Coetzee --- .../impl/clickhouse/configuration.py | 7 +++--- .../dlt-ecosystem/destinations/clickhouse.md | 22 ++++++++++++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/dlt/destinations/impl/clickhouse/configuration.py b/dlt/destinations/impl/clickhouse/configuration.py index 34bac5b43b..7d729933c0 100644 --- a/dlt/destinations/impl/clickhouse/configuration.py +++ b/dlt/destinations/impl/clickhouse/configuration.py @@ -41,9 +41,10 @@ class ClickHouseCredentials(ConnectionStringCredentials): "host", "port", "http_port", - "username", - "database", "secure", + "database", + "username", + "password", "connect_timeout", "send_receive_timeout", "dataset_table_separator", @@ -75,8 +76,6 @@ def to_url(self) -> URL: class ClickHouseClientConfiguration(DestinationClientDwhWithStagingConfiguration): destination_type: Final[str] = dataclasses.field(default="clickhouse", init=False, repr=False, compare=False) # type: ignore[misc] credentials: ClickHouseCredentials = None - dataset_name: Final[str] = dataclasses.field(default="", init=False, repr=False, compare=False) # type: ignore[misc] - """dataset name in the destination to load data to, for schemas that are not default schema, it is used as dataset prefix""" # Primary key columns are used to build a sparse primary index which allows for efficient data retrieval, # but they do not enforce uniqueness constraints. It permits duplicate values even for the primary key diff --git a/docs/website/docs/dlt-ecosystem/destinations/clickhouse.md b/docs/website/docs/dlt-ecosystem/destinations/clickhouse.md index f806a449e8..f2bcec33ab 100644 --- a/docs/website/docs/dlt-ecosystem/destinations/clickhouse.md +++ b/docs/website/docs/dlt-ecosystem/destinations/clickhouse.md @@ -43,10 +43,13 @@ To load data into ClickHouse, you need to create a ClickHouse database. While we 2. To create a new database, connect to your ClickHouse server using the `clickhouse-client` command line tool or a SQL client of your choice. -3. Run the following SQL command to create a new database: +3. Run the following SQL commands to create a new database, user and grant the necessary permissions: ```sql - CREATE DATABASE IF NOT EXISTS dlt_data; + CREATE DATABASE IF NOT EXISTS dlt; + CREATE USER dlt IDENTIFIED WITH sha256_password BY 'my_password' + GRANT ALL ON dlt.* TO dlt; + GRANT CREATE TEMPORARY TABLE, S3 ON *.* TO dlt; ``` ### 3. Add credentials @@ -55,17 +58,20 @@ To load data into ClickHouse, you need to create a ClickHouse database. While we ```toml [destination.clickhouse.credentials] - database = "dlt_data" # the database name you created - username = "default" # ClickHouse username, default is usually "default" - password = "" # ClickHouse password if any - host = "localhost" # ClickHouse server host - port = 9000 # ClickHouse HTTP port, default is 9000 - secure = false # set to true if using HTTPS + database = "dlt_data" # the database name you created + username = "default" # ClickHouse username, default is usually "default" + password = "" # ClickHouse password if any + host = "localhost" # ClickHouse server host + port = 9000 # ClickHouse HTTP port, default is 9000 + http_port = 8443 # HTTP Port to connect to ClickHouse server's HTTP interface. + secure = 1 # Set to 1 if using HTTPS, else 0. + dataset_table_separator = "___" # Separator for dataset table names, defaults to '___', i.e. 'database.dataset___table'. ``` 2. You can pass a database connection string similar to the one used by the `clickhouse-driver` library. The credentials above will look like this: ```toml + # keep it at the top of your toml file, before any section starts. destination.clickhouse.credentials="clickhouse://default:password@localhost/dlt_data?secure=false" ```