Files
zeekay 75dd1132bd rename: zero ClickHouse — datastore_connect speaks X-Datastore-*
The wire protocol was the last holdout and it was not cosmetic: the Hanzo
Datastore server reads X-Datastore-User, and answers a request bearing
X-ClickHouse-User with 401. Verified against the live server, both directions.
So a client still sending the old headers is not merely off-brand, it cannot
authenticate over HTTP.

Everything else follows: types, dialects, error modules, docstrings and doc
links now name Datastore, and doc URLs point at docs.hanzo.ai/datastore rather
than the upstream vendor's site. Zero occurrences of the old name remain.

Still cut from the pinned upstream version, so behaviour is unchanged.
2026-07-26 11:06:05 -07:00

29 lines
821 B
Python

from typing import NamedTuple, Sequence
from datastore_connect.datatypes.base import DatastoreType
class TableColumnDef(NamedTuple):
"""
Simplified Datastore Table Column definition for DDL
"""
name: str
ch_type: DatastoreType
expr_type: str = None
expr: str = None
@property
def col_expr(self):
expr = f'{self.name} {self.ch_type.name}'
if self.expr_type:
expr += f' {self.expr_type} {self.expr}'
return expr
def create_table(table_name: str, columns: Sequence[TableColumnDef], engine: str, engine_params: dict):
stmt = f"CREATE TABLE {table_name} ({', '.join(col.col_expr for col in columns)}) ENGINE {engine} "
if engine_params:
for key, value in engine_params.items():
stmt += f' {key} {value}'
return stmt