Skip to content

Commit 565fa11

Browse files
committed
chore: add default value to CHDB_DATA_PATH
1 parent 3c2ac44 commit 565fa11

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
CLICKHOUSE_SECURE: "false"
4040
CLICKHOUSE_VERIFY: "false"
4141
CHDB_ENABLED: "true"
42-
CHDB_DATA_PATH: ":memory:"
4342
run: |
4443
uv run pytest tests
4544

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ The following environment variables are used to configure the ClickHouse and chD
227227
* Default: `"false"`
228228
* Set to `"true"` to enable chDB tools
229229
* `CHDB_DATA_PATH`: The path to the chDB data directory
230-
* Required when `CHDB_ENABLED=true`
231-
* Use `:memory:` for in-memory database (recommended for testing)
230+
* Default: `":memory:"` (in-memory database)
231+
* Use `:memory:` for in-memory database
232232
* Use a file path for persistent storage (e.g., `/path/to/chdb/data`)
233233

234234
#### Example Configurations
@@ -274,7 +274,7 @@ For chDB only (in-memory):
274274
# chDB configuration
275275
CHDB_ENABLED=true
276276
CLICKHOUSE_ENABLED=false
277-
CHDB_DATA_PATH=:memory:
277+
# CHDB_DATA_PATH defaults to :memory:
278278
```
279279

280280
For chDB with persistent storage:

mcp_clickhouse/mcp_env.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def enabled(self) -> bool:
197197
@property
198198
def data_path(self) -> str:
199199
"""Get the chDB data path."""
200-
return os.environ["CHDB_DATA_PATH"]
200+
return os.getenv("CHDB_DATA_PATH", ":memory:")
201201

202202
def get_client_config(self) -> dict:
203203
"""Get the configuration dictionary for chDB client.
@@ -215,8 +215,7 @@ def _validate_required_vars(self) -> None:
215215
Raises:
216216
ValueError: If any required environment variable is missing.
217217
"""
218-
if self.enabled and "CHDB_DATA_PATH" not in os.environ:
219-
raise ValueError("Missing required environment variable: CHDB_DATA_PATH")
218+
pass
220219

221220

222221
# Global instance placeholders for the singleton pattern

mcp_clickhouse/mcp_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ def _init_chdb_client():
328328

329329
if get_chdb_config().enabled:
330330
_chdb_client = _init_chdb_client()
331-
atexit.register(lambda: _chdb_client.close() if _chdb_client is not None else None)
331+
if _chdb_client:
332+
atexit.register(lambda: _chdb_client.close())
332333

333334
mcp.add_tool(run_chdb_select_query)
334335
chdb_prompt = Prompt.from_function(

0 commit comments

Comments
 (0)