mirror of
https://github.com/hanzo-ds/connect.git
synced 2026-10-30 20:31:24 +00:00
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.
41 lines
1.7 KiB
Python
41 lines
1.7 KiB
Python
from sqlalchemy.sql.ddl import DDL
|
|
from sqlalchemy.exc import ArgumentError
|
|
|
|
from datastore_connect.driver.binding import quote_identifier
|
|
|
|
|
|
# pylint: disable=too-many-ancestors,abstract-method
|
|
class CreateDatabase(DDL):
|
|
"""
|
|
SqlAlchemy DDL statement that is essentially an alternative to the built in CreateSchema DDL class
|
|
"""
|
|
# pylint: disable-msg=too-many-arguments
|
|
def __init__(self, name: str, engine: str = None, zoo_path: str = None, shard_name: str = '{shard}',
|
|
replica_name: str = '{replica}'):
|
|
"""
|
|
:param name: Database name
|
|
:param engine: Database Datastore engine type
|
|
:param zoo_path: Datastore zookeeper path for Replicated database engine
|
|
:param shard_name: Datastore shard name for Replicated database engine
|
|
:param replica_name: Replica name for Replicated database engine
|
|
"""
|
|
if engine and engine not in ('Ordinary', 'Atomic', 'Lazy', 'Replicated'):
|
|
raise ArgumentError(f'Unrecognized engine type {engine}')
|
|
stmt = f'CREATE DATABASE {quote_identifier(name)}'
|
|
if engine:
|
|
stmt += f' Engine {engine}'
|
|
if engine == 'Replicated':
|
|
if not zoo_path:
|
|
raise ArgumentError('zoo_path is required for Replicated Database Engine')
|
|
stmt += f" ('{zoo_path}', '{shard_name}', '{replica_name}'"
|
|
super().__init__(stmt)
|
|
|
|
|
|
# pylint: disable=too-many-ancestors,abstract-method
|
|
class DropDatabase(DDL):
|
|
"""
|
|
Alternative DDL statement for built in SqlAlchemy DropSchema DDL class
|
|
"""
|
|
def __init__(self, name: str):
|
|
super().__init__(f'DROP DATABASE {quote_identifier(name)}')
|