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-mePython
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.
-
Download and install the latest DBeaver Community Edition.
-
Create a new connection (Database → New Database Connection).
-
Choose ClickHouse as the connection type. DBeaver will download the driver the first time you use it.
-
Fill in the connection settings from your OnchainDivers credentials:
Setting Value Host CLICKHOUSE_HOST(e.g.clickhouse.example.com)Port 8123(ClickHouse HTTP port)Username CLICKHOUSE_USERNAMEPassword CLICKHOUSE_PASSWORD -
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.