{
  "id": 9952066,
  "title": "Stop writing raw ClickHouse DDL: A Pydantic v2 model is enough",
  "url": "https://urgent.news/2026/09/26/stop-writing-raw-clickhouse-ddl-a-pydantic-v2-model-is-enough",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-26T09:27:06.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/william_rodriguez_65a5898/stop-writing-raw-clickhouse-ddl-a-pydantic-v2-model-is-enough-71p"
  },
  "original_language": "en",
  "account": "On Day 01 of the WClickHouse Open-Source Engineering Series, engineers are abandoning manual SQL DDL strings in Python. WClickHouse effortlessly binds Pydantic v2 models to ClickHouse columnar storage. Engineers previously spent 40 lines crafting CREATE TABLE DDLs for each analytical event. Mismatches between Python types and ClickHouse columnar storage engines caused runtime data corruption from unvalidated dictionaries inserted into tables. The implementation leverages the pydantic import BaseModel, the wclickhouse import WClickHouse, the datetime import datetime, and the typing import List. The AnalyticsEvent class, derived from BaseModel, encompasses event_id, event_name, properties, and created_at. The db = WClickHouse(AnalyticsEvent, db_config) line initializes the database with the AnalyticsEvent model and the designated database configuration. The db.insert(AnalyticsEvent(event_id=1, event_name=\"click\", properties=[\"web\", \"cta\"])) command inserts the event into the database. Pydantic v2's native architecture offers a 1:1 mapping of model fields to ClickHouse columns, automatic DDL generation executing CREATE TABLE IF NOT EXISTS with optimal engines. Strict validation verifies types in memory before transmitting bytes to the server, ensuring data integrity. The architecture has undergone rigorous testing and verification against live ClickHouse server instances, boasting over 95% test coverage. The framework is designed for Python versions 3.9 through 3.14, integrating Apache Arrow and Pydantic v2. For more information, visit the GitHub repository at https://github.com/wisrovi/wclickhouse, or the PyPI page at https://pypi.org/project/wclickhouse.",
  "summary": "Day 01 of the WClickHouse Open-Source Engineering Series. Why are engineers still writing manual SQL DDL strings in Python? WClickHouse binds Pydantic v2 models directly to ClickHouse columnar storage. The Pain Points We Faced Writing 40-line CREATE TABLE DDLs by hand for every analytical event Mismatches between Python types and ClickHouse columnar storage engines Runtime data corruption from…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 2,
    "also_reported_by": [
      {
        "outlet": "Dev.to",
        "title": "[ES] Deja de escribir DDL de ClickHouse a mano: Un modelo Pydantic v2 es suficiente",
        "url": "https://urgent.news/2026/09/26/es-deja-de-escribir-ddl-de-clickhouse-a-mano-un-modelo-pydantic-v2-es",
        "published": "2026-09-26T08:36:33.000Z"
      }
    ]
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}