Skip to content

Commit

Permalink
Remove empty dataset default #1055
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Coetzee <[email protected]>
  • Loading branch information
Pipboyguy committed Apr 11, 2024
1 parent b13942b commit dce1967
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
7 changes: 3 additions & 4 deletions dlt/destinations/impl/clickhouse/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
22 changes: 14 additions & 8 deletions docs/website/docs/dlt-ecosystem/destinations/clickhouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
```

Expand Down

0 comments on commit dce1967

Please sign in to comment.