Summary
Add a clickhousectl local server dotenv command that writes standard ClickHouse connection environment variables into a .env file (or .env.local with --local), making it easy to configure apps that read from dotenv files.
Proposed CLI
clickhousectl local server dotenv [--name <server-name>] [--local]
--name <server-name> — target a specific named server (defaults to default)
--local — write to .env.local instead of .env
Behavior
- Read the connection details for the given server (host, port, user, password, database, etc.)
- Write opinionated env var names into the target file, e.g.:
CLICKHOUSE_HOST=localhost
CLICKHOUSE_PORT=9000
CLICKHOUSE_HTTP_PORT=8123
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=
CLICKHOUSE_DATABASE=default
- If the
.env / .env.local file already exists, find and replace any existing CLICKHOUSE_* vars in-place rather than appending duplicates
- If the file doesn't exist, create it with just the ClickHouse vars
Use case
When switching between servers (e.g. dev vs staging), you can quickly swap your app's ClickHouse connection config:
clickhousectl local server dotenv --name dev
# .env now points to dev server
clickhousectl local server dotenv --name staging
# .env now points to staging server
Using --local lets you keep a .env.local override that isn't committed to git, which is the common convention for local-only config.
Summary
Add a
clickhousectl local server dotenvcommand that writes standard ClickHouse connection environment variables into a.envfile (or.env.localwith--local), making it easy to configure apps that read from dotenv files.Proposed CLI
--name <server-name>— target a specific named server (defaults todefault)--local— write to.env.localinstead of.envBehavior
.env/.env.localfile already exists, find and replace any existingCLICKHOUSE_*vars in-place rather than appending duplicatesUse case
When switching between servers (e.g.
devvsstaging), you can quickly swap your app's ClickHouse connection config:Using
--locallets you keep a.env.localoverride that isn't committed to git, which is the common convention for local-only config.