> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect to ClickHouse

## Credentials

DirectQuery delegates the credentials handling to the ClickHouse server.

The credentials, based on a username and password, are passed via `ClickhouseConfiguration` to the server:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
final ClickhousePropertiesV2 properties =
    ClickhousePropertiesV2.builder()
        .host(HOST)
        .protocol(Protocol.HTTP)
        .port(port)
        .database("TUTORIAL")
        .userName(USERNAME)
        .password(PASSWORD)
        .build();
final ClickhouseClientSettings clientSettings =
    ClickhouseClientSettings.builder().propertiesV2(properties).build();
```

The ClickHouse server can be configured to handle these credentials in various ways, such as checking internally
or externally with an LDAP server.

## Permissions

ClickHouse is using standard SQL permissions via the granting of roles to the user.

For DirectQuery, the user should at a minimum have read permissions on some system tables
(`system.databases`, `system.processes`, `system.tables` and `system.columns`) and all the tables containing relevant data.

The permissions can be granted by following this [role guide](https://clickhouse.com/docs/en/operations/access-rights).
