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()

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