Commit 82f1f4e
authored
feat: add pyseekdb CLI entry point in pyproject.toml (#161)
Introduce a **CLI for pyseekdb** to support debugging and managing
SeekDB databases/collections (close #55).
### Changes
- **CLI 模块**
- 新增
`src/pyseekdb/cli/__init__.py`、`src/pyseekdb/cli/main.py`,实现命令行入口与子命令分发。
- **连接方式**(与 spec 一致)
- 嵌入式:`--path`(默认当前目录下 `seekdb.db`)。
- 服务端:`--host`、`--port`(默认
2881)、`--tenant`、`--database`、`--user`、`--password`(或环境变量
`SEEKDB_PASSWORD`)。
- **子命令**
- **db**:`list` / `create <name>` / `delete <name>`(数据库管理)。
- **collections**(别名 **coll**):`list` / `create <name> [--dimension N]`
/ `delete <name>` / `info <name> [--sample N]`(collection 管理及预览)。
- **sql**:执行原始 SQL(调试用)。
- **query**:按文本对指定 collection 做向量/语义查询(`--text`、`--n`)。
- **get**:按 id 或 limit 拉取 collection 文档(`--ids`、`--limit`)。
- **输出**:全局 `-o table`(默认)或 `-o json`。
- **入口**:在 `pyproject.toml` 中增加 `[project.scripts]`,将 `pyseekdb` 指向
`pyseekdb.cli:main`。
## Solution Description
针对 [issue #55](https://github.com/oceanbase/pyseekdb/issues/55),基于现有
`Client` / `AdminClient` 和 spec 中的连接与能力说明,实现一个统一的 CLI,便于:
- **管理**:列出/创建/删除数据库与 collections,查看 collection 信息与样本数据。
- **调试**:执行任意 SQL、对 collection 做 query/get,支持 table 与 json 两种输出。
CLI 复用 `Client()` 与 `AdminClient()`
的工厂逻辑,支持嵌入式(`--path`)与服务端(`--host`/`--port` 等)两种模式;子命令通过 argparse
组织,无额外依赖。
## Test plan
- 安装后执行 `pyseekdb --help`、`pyseekdb db --help`、`pyseekdb collections
--help` 等,确认子命令与参数展示正确。
- 在嵌入式或服务端环境下分别验证:`db list`、`collections list`、`collections info <name>
--sample N`、`sql "SHOW TABLES"`、`query <collection> --text "..."`、`get
<collection> --limit N` 及 `-o json` 输出,确认无报错且结果符合预期。
related to #55
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Packs a command-line interface (CLI) as a public executable entry
point.
* Adds DB management commands: list, create, delete.
* Adds collection commands: list, create, delete, info (with optional
sample).
* Adds query, document retrieval, and raw SQL execution commands.
* Supports embedded/server connection modes, configurable credentials,
and output formats (table or JSON).
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent dc87918 commit 82f1f4e
3 files changed
Lines changed: 417 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments