Skip to main content

ClickHouse

clickhousectl

Slack community Follow on X YouTube videos

clickhousectl (chctl) is the official CLI for ClickHouse, from local development to ClickHouse Cloud.

What can the CLI do?

  • ClickHouse is the open-source, column-oriented SQL database for analytics. Install and switch local versions, run isolated servers, and execute SQL.
  • ClickHouse Cloud runs ClickHouse as a managed service on AWS, GCP, and Azure. Create, configure, scale, back up, and query services from the terminal.
  • ClickHouse Managed Postgres runs PostgreSQL for transactional applications, with ClickHouse integration for analytics. Use Docker-backed Postgres locally, then create, monitor, configure, and restore managed services in Cloud.
  • ClickPipes ingests data into ClickHouse Cloud from object storage, streams, and databases through change data capture. Create, inspect, update, scale, and troubleshoot pipelines.
  • ClickStack combines ClickHouse, OpenTelemetry, and the HyperDX UI for observability. Manage sources, roles, saved searches, dashboards, alerts, and webhooks for an existing Managed ClickStack service.

The CLI also manages organization access and installs official ClickHouse skills for coding agents.

Install

Supports macOS and Linux on Apple Silicon/ARM64 and x86_64.

curl -fsSL https://clickhouse.com/cli | sh

The script installs to ~/.local/bin/clickhousectl and creates the chctl alias. Ensure ~/.local/bin is on your PATH.

Other installation options:

Tool Command
npm npm install -g clickhousectl
uv uv tool install clickhousectl
pipx pipx install clickhousectl
pip pip install clickhousectl
cargo-binstall cargo binstall clickhousectl
Cargo, from source (Rust 1.94+) cargo install clickhousectl

Check for or install a CLI update:

clickhousectl update --check
clickhousectl update

Start locally

Use the latest channel for the rolling master build of ClickHouse. A bare server start installs latest if no version or default is available.

clickhousectl local server start dev --version latest
clickhousectl local client dev --query "SELECT version()"
clickhousectl local server stop dev

Run these from the same project directory. Each named server has isolated data under .clickhouse/; stopping preserves it for the next start.

For local Postgres, start Docker first:

clickhousectl local postgres start dev
clickhousectl local postgres client dev --query "SELECT version()"
clickhousectl local postgres stop dev

Continue with local development for SQL files, version selection, configuration, and cleanup.

Connect to ClickHouse Cloud

Create a ClickHouse Cloud account if needed to get $300 in free trial credits, then sign in:

clickhousectl cloud auth signup
clickhousectl cloud auth login

Browser OAuth is read-only. Creating or changing resources requires an API key with the appropriate roles. Use either an interactive prompt or a .env file to supply your API key.

To save the key interactively without putting its secret in shell history:

clickhousectl cloud auth login --interactive

Alternatively, create a .env file in your project with your keys:

CLICKHOUSE_CLOUD_API_KEY=your-api-key
CLICKHOUSE_CLOUD_API_SECRET=your-api-secret

Keep .env out of version control by adding it to .gitignore.

OAuth tokens are global (~/.clickhouse/tokens.json); saved API keys are project-local (.clickhouse/credentials.json). For CI, inject CLICKHOUSE_CLOUD_API_KEY and CLICKHOUSE_CLOUD_API_SECRET through your secret manager. See authentication and permissions for precedence, organization selection, and logout.

Create and query ClickHouse

Create a ClickHouse Cloud service. Save the initial password shown at creation; it is only returned once.

# Output will contain the service ID
clickhousectl cloud service create --name analytics \
  --provider aws --region us-east-1

Creation returns before provisioning finishes. Queries use OAuth for read-only SQL or an API key for permitted reads and writes. On first use, API-key queries can bind the caller's key to the service's Query API endpoint; use --no-auto-enable to require an existing binding.

The Query API may time out while SQL continues running. Check the outcome before retrying a write. Use a native client for long queries and bulk loads. Named endpoint lists return one page; pass pagination.nextCursor from JSON output to query-api-endpoint list --cursor to continue. See create and operate a Cloud service and SQL and Query API behavior.

Create ClickHouse Managed Postgres

clickhousectl cloud postgres create --name app-db \
  --provider aws --region us-east-1 --size c6gd.xlarge --pg-version 18
clickhousectl cloud postgres get <postgres-id>
clickhousectl cloud postgres certs get <postgres-id> --output ca.pem

Save any initial password and connection string, wait for state=running, then connect with psql using verified TLS. The ClickHouse Managed Postgres guide covers that flow, configuration changes, read-only OAuth queries, and recovery. ClickHouse Managed Postgres commands are beta.

Ingest with ClickPipes

Use ClickPipes to replicate database changes or load files into ClickHouse Cloud. Both examples require API-key authentication and a running ClickHouse destination.

Replicate ClickHouse Managed Postgres into ClickHouse

Start with the analytics ClickHouse service and app-db ClickHouse Managed Postgres service created above. Use their returned IDs below, and wait until both report state=running:

clickhousectl cloud service get <service-id>
clickhousectl cloud postgres get <postgres-id>
clickhousectl cloud postgres certs get <postgres-id> --output ca.pem

Set POSTGRES_HOST, POSTGRES_USERNAME, and POSTGRES_PASSWORD from the ClickHouse Managed Postgres connection details saved at creation. Use the direct Postgres endpoint, not PgBouncer. For this quickstart, use the initial database user; ClickHouse Managed Postgres already has logical replication enabled.

Create a sample table and a publication using psql. The cloud postgres query command only supports read-only SQL through OAuth, so it cannot run these setup statements:

PGPASSWORD="$POSTGRES_PASSWORD" psql \
  "host=$POSTGRES_HOST port=5432 dbname=postgres user=$POSTGRES_USERNAME sslmode=verify-full sslrootcert=ca.pem" \
  -v ON_ERROR_STOP=1 <<'SQL'
CREATE TABLE public.orders (id bigint PRIMARY KEY, status text NOT NULL);
INSERT INTO public.orders VALUES (1, 'new');
CREATE PUBLICATION clickpipes_demo FOR TABLE public.orders;
SQL

Create a ClickPipe to copy the existing rows and continuously replicate inserts, updates, and deletes. The CA file keeps certificate verification enabled:

clickhousectl cloud clickpipe create postgres <service-id> \
  --name orders-cdc --host "$POSTGRES_HOST" --pg-database postgres \
  --username "$POSTGRES_USERNAME" --password "$POSTGRES_PASSWORD" \
  --ca-certificate ca.pem --publication-name clickpipes_demo \
  --replication-mode cdc --destination-database default \
  --table-mapping public.orders:orders

Use the returned ClickPipe ID to check its state, then query the current rows in ClickHouse after the initial load:

clickhousectl cloud clickpipe get <service-id> <clickpipe-id>
clickhousectl cloud service query <service-id> \
  --query "SELECT id, status FROM default.orders FINAL WHERE _peerdb_is_deleted = 0"

To check ongoing CDC, run UPDATE public.orders SET status = 'paid' WHERE id = 1; in Postgres and repeat the ClickHouse query. Replication is asynchronous, so allow time for the change to arrive.

Load files from S3

For a private bucket, set S3_IAM_ROLE_ARN to a role configured to let ClickPipes read your objects. Replace the example URL, discover the schema, then choose the columns to ingest. This example expects event_id and event_type fields in JSONEachRow files:

S3_URL='https://example-bucket.s3.amazonaws.com/events/**'
clickhousectl cloud clickpipe schema-discover object-storage <service-id> \
  --storage-type s3 --source-url "$S3_URL" --format JSONEachRow \
  --iam-role "$S3_IAM_ROLE_ARN"

clickhousectl cloud clickpipe create object-storage <service-id> \
  --name s3-events --storage-type s3 --source-url "$S3_URL" \
  --format JSONEachRow --iam-role "$S3_IAM_ROLE_ARN" \
  --database default --table s3_events \
  --column 'event_id:Int64' --column 'event_type:String'

This starts a one-time load of the matching objects. Check the returned ClickPipe ID and verify the loaded data:

clickhousectl cloud clickpipe get <service-id> <clickpipe-id>
clickhousectl cloud service query <service-id> --query "SELECT count() FROM default.s3_events"

See the ClickPipes guide for source permissions and networking, other sources, continuous S3 ingestion, monitoring, and safe updates.

Configure ClickStack

Use an existing Managed ClickStack service and a complete dashboard definition:

clickhousectl cloud clickstack source list <service-id>
clickhousectl cloud clickstack dashboard validate <service-id> --file dashboard.json
clickhousectl cloud clickstack dashboard create <service-id> --file dashboard.json

All ClickStack updates replace the complete resource. The ClickStack guide includes a dashboard definition and a review-before-replace workflow.

Use with coding agents and scripts

Install official ClickHouse skills into the current project, or add --global for your home directory:

clickhousectl skills --agent claude --agent codex

The common .agents/skills/ directory is always included. Run skills without flags for interactive selection; unattended installs require --agent, --all, or --detected-only.

Structured commands support --json and select it automatically for detected coding agents. SQL and native clients retain command-specific formats. Always check the exit status and distinguish an accepted request from a completed operation. See automation and output contracts.

Documentation

Documentation Covers
Local development Local ClickHouse and Postgres, versions, configuration, and cleanup
ClickHouse Cloud services Create, query, scale, back up, and remove services
ClickHouse Managed Postgres Connect, query, configure, and recover services
ClickPipes Load files, replicate databases, verify ingestion, and update pipelines
ClickStack Sources, dashboards, alerts, and safe resource updates
User-defined functions Test executable UDFs locally, then deploy and update them in Cloud
Authentication and access OAuth, API keys, credential precedence, roles, and logout
SQL and Query API Key binding, SQL input, output, timeouts, and named endpoints
ClickPipe configuration Partial updates, table mappings, source credentials, and private connectivity
Automation and output contracts JSON output, exit codes, asynchronous operations, and retries
Telemetry Recorded fields, opt-out, and local inspection
Contributing Build, checks, and documentation placement
CLI development Code layout, tests, live integration suites, and debugging
Rust API library Typed Cloud API client, usage examples, and API coverage

Telemetry

The CLI collects anonymous command usage and bounded failure categories, never argument values, SQL, credentials, or an installation/device ID. The first-run notice sends nothing; collection starts on a following run unless disabled.

clickhousectl telemetry disable
clickhousectl telemetry status

DO_NOT_TRACK=1 also disables collection. See telemetry details and controls.

Contribute

See CONTRIBUTING.md for setup, checks, and documentation placement, and CLI development for the code layout and test workflows.

Metadata

Release files for clickhousectl 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for clickhousectl 0.5.0
File
clickhousectl-0.5.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details
clickhousectl-0.5.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details
clickhousectl-0.5.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details
clickhousectl-0.5.0-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details
clickhousectl-0.5.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
clickhousectl-0.5.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details

Total release size: 52.4 MB

Release files / clickhousectl-0.5.0-py3-none-musllinux_1_2_x86_64.whl

Download URL clickhousectl-0.5.0-py3-none-musllinux_1_2_x86_64.whl
Size 9.2 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
21ab645a0175b671985a3576314e26aaec9d641c0703c0a53fc88d38af45ad00
BLAKE2b-256 checksum
How to use checksums
64bee102e8f9a637e172be4d73abb28f62da1f0c7736a3ce380526b4bfcb4076
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / clickhousectl-0.5.0-py3-none-musllinux_1_2_aarch64.whl

Download URL clickhousectl-0.5.0-py3-none-musllinux_1_2_aarch64.whl
Size 8.5 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
6ba321b6a5b8c764b6cf4e62287f911ba1007affffacb53cb4149f869666b082
BLAKE2b-256 checksum
How to use checksums
5c93a79d715c9db6d6163acb99795430720b8f1ed5df9bd8570aa49b29398ec5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / clickhousectl-0.5.0-py3-none-manylinux_2_28_x86_64.whl

Download URL clickhousectl-0.5.0-py3-none-manylinux_2_28_x86_64.whl
Size 9.1 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
9fd2625695bc5d3c09617d6951dcc048fe166018e080bf32fc64b1ebf75b3d96
BLAKE2b-256 checksum
How to use checksums
8874ebed5ce3512d30b0d3853695faf05b008d66a89ccd0c570573eef9f28b23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / clickhousectl-0.5.0-py3-none-manylinux_2_28_aarch64.whl

Download URL clickhousectl-0.5.0-py3-none-manylinux_2_28_aarch64.whl
Size 8.4 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
b2ba691d6db407982b8a3a27d337dfe61d1ac20440fd5164dc4fc3b869c03359
BLAKE2b-256 checksum
How to use checksums
b9b01c3eb6b90c203613c5b344e52aa296f6209eb2964c2d55115d03eb52dbe6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / clickhousectl-0.5.0-py3-none-macosx_11_0_arm64.whl

Download URL clickhousectl-0.5.0-py3-none-macosx_11_0_arm64.whl
Size 8.5 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a75b34e6403b5865a2245a4eabcd81fdc48474daab6a1cd99b57fbc0ce85f4fc
BLAKE2b-256 checksum
How to use checksums
c8d9e970d688a515ffcb8e44c7b4183b00e12f8a0c233d64543ff8dd8b505ec9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / clickhousectl-0.5.0-py3-none-macosx_10_12_x86_64.whl

Download URL clickhousectl-0.5.0-py3-none-macosx_10_12_x86_64.whl
Size 8.8 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
027ad9f5f06dbd5749be29b1718292b517d75dcf0efc65c1e377682de65cf713
BLAKE2b-256 checksum
How to use checksums
335bee26929b79c80966a1e9077ee46a364439b3dc34baf16ee53bfa699a7133
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for clickhousectl 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for clickhousectl-0.5.0-py3-none-musllinux_1_2_x86_64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page