Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Connect to the Solana indexer

Connection details are provided with your OnchainDivers credentials. Keep them in environment variables or a local .env; do not embed them in source code.

CLICKHOUSE_HOST=clickhouse.example.com
CLICKHOUSE_PORT=8123
CLICKHOUSE_USERNAME=docs_reader
CLICKHOUSE_PASSWORD=replace-me

Python

import os
import clickhouse_connect
 
client = clickhouse_connect.get_client(
    host=os.environ["CLICKHOUSE_HOST"],
    port=int(os.environ.get("CLICKHOUSE_PORT", "8123")),
    username=os.environ["CLICKHOUSE_USERNAME"],
    password=os.environ["CLICKHOUSE_PASSWORD"],
)
 
rows = client.query("SELECT now() AS server_time").named_results()
print(rows)
client.close()

Install the client with pip install clickhouse-connect.

Repository client

The examples use scripts/clickhouse_accessors.py, which reads the same keys from .env, returns rows as dictionaries, and closes the connection explicitly.

from scripts.clickhouse_accessors import ClickHouseAccessor
 
client = ClickHouseAccessor(".env")
try:
    rows = client.query("SELECT count() AS rows FROM token_transfers")
    print(rows[0])
finally:
    client.disconnect()

DBeaver (GUI)

Prefer a graphical client? DBeaver is a free, cross-platform SQL tool with a built-in ClickHouse driver — useful for browsing tables and prototyping queries before moving them into code.

  1. Download and install the latest DBeaver Community Edition.

  2. Create a new connection (Database → New Database Connection).

  3. Choose ClickHouse as the connection type. DBeaver will download the driver the first time you use it.

  4. Fill in the connection settings from your OnchainDivers credentials:

    SettingValue
    HostCLICKHOUSE_HOST (e.g. clickhouse.example.com)
    Port8123 (ClickHouse HTTP port)
    UsernameCLICKHOUSE_USERNAME
    PasswordCLICKHOUSE_PASSWORD
  5. Click Test Connection to verify the settings, then Finish to save.

Inspect a table's structure

Understanding the schema is key to writing effective queries. To view a table's definition, right-click it in the Database Navigator, choose Generate SQL → DDL, and review the generated CREATE TABLE statement. From there you can write queries that select, filter, and aggregate the columns you need.

Continue with the verified Solana examples or inspect the generated table reference.