clickhouse-pydantic-config
Original:🇺🇸 English
Translated
2 scriptsChecked / no sensitive code detected
Generate DBeaver config from Pydantic ClickHouse models. TRIGGERS - DBeaver config, ClickHouse connection, database client config.
18installs
Sourceterrylica/cc-skills
Added on
NPX Install
npx skill4agent add terrylica/cc-skills clickhouse-pydantic-configTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →ClickHouse Pydantic Config
<!-- ADR: 2025-12-09-clickhouse-pydantic-config-skill -->Generate DBeaver database client configurations from Pydantic v2 models using mise as Single Source of Truth (SSoT).
[env]When to Use This Skill
Use this skill when:
- Setting up DBeaver connections for ClickHouse databases
- Generating database client configurations from environment variables
- Managing local vs cloud ClickHouse connection profiles
- Integrating ClickHouse with mise-based development workflows
- Automating DBeaver data-sources.json generation
Critical Design Principle: Semi-Prescriptive Adaptation
This skill is NOT a rigid template. It provides a SSoT pattern that MUST be adapted to each repository's structure and local database situation.
Why This Matters
Each repository has unique:
- Directory layouts (location may vary)
.dbeaver/ - Environment variable naming conventions
- Existing connection management patterns
- Local vs cloud database mix
The SSoT principle is the constant; the implementation details are the variables.
Quick Start
bash
# Generate local connection config
mise run db-client-generate
# Generate cloud connection config
mise run db-client:cloud
# Preview without writing
mise run db-client:dry-run
# Launch DBeaver
mise run dbeaverCredential Prerequisites (Cloud Mode)
<!-- ADR: 2025-12-10-clickhouse-skill-documentation-gaps -->Before using cloud mode, obtain credentials via the skill chain:
- Create/retrieve user: Use skill to create read-only users or retrieve existing credentials from 1Password
clickhouse-cloud-management - Store in .env: Add to file (gitignored):
.env
bash
CLICKHOUSE_USER_READONLY=your_user
CLICKHOUSE_PASSWORD_READONLY=your_password- Generate config: Run
mise run db-client:cloud
Skill chain: → →
clickhouse-cloud-management.envclickhouse-pydantic-configmise [env]
as Single Source of Truth
[env]All configurable values live in :
.mise.tomltoml
[env]
CLICKHOUSE_NAME = "clickhouse-local"
CLICKHOUSE_MODE = "local" # "local" or "cloud"
CLICKHOUSE_HOST = "localhost"
CLICKHOUSE_PORT = "8123"
CLICKHOUSE_DATABASE = "default"Scripts read from with backward-compatible defaults—works with or without mise installed.
os.environ.get()Credential Handling by Mode
| Mode | Approach | Rationale |
|---|---|---|
| Local | Hardcode | Zero friction, no security concern |
| Cloud | Pre-populate from | Read from environment, write to gitignored JSON |
Key principle: The generated is gitignored anyway. Pre-populating credentials trades zero security risk for maximum developer convenience.
data-sources.jsonCloud Credentials Setup
bash
# .env (gitignored)
CLICKHOUSE_USER_READONLY=readonly_user
CLICKHOUSE_PASSWORD_READONLY=your-secret-passwordRepository Adaptation Workflow
Pre-Implementation Discovery (Phase 0)
Before writing any code, the executor MUST:
bash
# 1. Discover existing configuration patterns
fd -t f ".mise.toml" .
fd -t f ".env*" .
fd -t d ".dbeaver" .
# 2. Test ClickHouse connectivity (local)
clickhouse-client --host localhost --port 9000 --query "SELECT 1"
# 3. Check for existing connection configs
fd -t f "data-sources.json" .
fd -t f "dataSources.xml" .Adaptation Decision Matrix
| Discovery Finding | Adaptation Action |
|---|---|
Existing | Extend existing |
Existing | Merge connections, preserve existing entries |
| Non-standard CLICKHOUSE_* vars | Map to repository's naming convention |
| Multiple databases (local + cloud) | Generate multiple connection entries |
| No ClickHouse available | Warn and generate placeholder config |
Validation Checklist (Post-Generation)
The executor MUST verify:
- Generated JSON is valid ()
jq . .dbeaver/data-sources.json - DBeaver can import the config (launch and verify connection appears)
- mise tasks execute without error ()
mise run db-client-generate - added to
.dbeaver/.gitignore
Pydantic Model
The model provides:
ClickHouseConnection- Type-safe configuration with Pydantic v2 validation
- Computed fields for JDBC URL and connection ID
- Mode-aware defaults (cloud auto-enables SSL on port 8443)
- Environment loading via class method
from_env()
See references/pydantic-model.md for complete model documentation.
DBeaver Format
DBeaver uses with this structure:
.dbeaver/data-sources.jsonjson
{
"folders": {},
"connections": {
"clickhouse-jdbc-{random-hex}": {
"provider": "clickhouse",
"driver": "com_clickhouse",
"name": "Connection Name",
"configuration": { ... }
}
}
}Important: DBeaver does NOT support substitution—values must be pre-populated at generation time.
${VAR}See references/dbeaver-format.md for complete format specification.
macOS Notes
- DBeaver binary: Use (NOT
/Applications/DBeaver.app/Contents/MacOS/dbeaver)open -a - Gitignore: Add to
.dbeaver/.gitignore
Related Skills
| Skill | Integration |
|---|---|
| Credential retrieval for cloud mode |
| Schema design context |
| SSoT environment variable patterns |
Python Driver Policy
For Python application code connecting to ClickHouse (not DBeaver), use (official HTTP driver). See for:
clickhouse-connectclickhouse-architect- Recommended code patterns
- Why NOT to use (community)
clickhouse-driver - Performance vs maintenance trade-offs
Additional Resources
| Reference | Content |
|---|---|
| references/pydantic-model.md | Complete model documentation |
| references/dbeaver-format.md | DBeaver JSON format spec |
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| DBeaver can't connect | Port mismatch (8123 vs 9000) | HTTP uses 8123, native uses 9000 - check config |
| Credentials not loading | .env not sourced | Run |
| JSON validation fails | Invalid data-sources.json | Validate with |
| Cloud SSL error | Missing SSL on port 8443 | Cloud mode auto-enables SSL - verify port is 8443 |
| mise task not found | Missing task definition | Add task to mise.toml |
| .dbeaver/ in git | Missing gitignore entry | Add |
| Connection ID conflict | Duplicate connection names | Each connection needs unique ID (random hex) |
| Config not updating | DBeaver caching | Restart DBeaver to reload data-sources.json |