From 652eaea0fc0aab6e04541373512f472249b47567 Mon Sep 17 00:00:00 2001 From: Andrey Zax Date: Wed, 13 Sep 2023 17:00:19 +0300 Subject: [PATCH] Add quotes around db & cluster name to allow full range of identifiers --- src/clickhouse_migrations/clickhouse_cluster.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clickhouse_migrations/clickhouse_cluster.py b/src/clickhouse_migrations/clickhouse_cluster.py index 27d446e..013f8c3 100644 --- a/src/clickhouse_migrations/clickhouse_cluster.py +++ b/src/clickhouse_migrations/clickhouse_cluster.py @@ -36,10 +36,10 @@ def connection(self, db_name: str) -> Client: def create_db(self, db_name, cluster_name=None): with self.connection("") as conn: if cluster_name is None: - conn.execute(f"CREATE DATABASE IF NOT EXISTS {db_name}") + conn.execute(f'CREATE DATABASE IF NOT EXISTS "{db_name}"') else: conn.execute( - f"CREATE DATABASE IF NOT EXISTS {db_name} ON CLUSTER {cluster_name}" + f'CREATE DATABASE IF NOT EXISTS "{db_name}" ON CLUSTER "{cluster_name}"' ) def init_schema(self, db_name, cluster_name=None):