seekdb-cli
Original:🇺🇸 English
Translated
Use seekdb-cli to interact with seekdb/OceanBase databases via shell commands. Use when: (1) querying databases with SQL, (2) exploring table schemas and structure, (3) profiling table data distributions, (4) inferring table relationships, (5) managing vector collections and semantic search, (6) adding/exporting collection data, (7) managing AI models , (8) checking database connection status, or (9) performing any database operation via command line.
4installs
Added on
NPX Install
npx skill4agent add oceanbase/seekdb-ecology-plugins seekdb-cliTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →seekdb-cli — AI-Agent Database CLI
A command-line client designed for AI Agents. All output is JSON-structured, stateless, with built-in safety guardrails.
Prerequisites
Check if seekdb-cli is installed (either command works—they share the same entry point):
bash
seekdb --version
# or, aligned with PyPI package name / for `which`-style checks:
seekdb-cli --versionIf not installed, choose the method that matches your environment:
Recommended — pipx (works globally without polluting system Python):
bash
# Install pipx first if needed (Ubuntu/Debian)
sudo apt install pipx && pipx ensurepath
# Then install seekdb-cli
pipx install seekdb-cliAlternative — pip (when inside a project venv or on systems without PEP 668):
bash
pip install seekdb-cliNote for Ubuntu 23.04+ / Debian 12+: Directat the system level is blocked by PEP 668. Usepip installinstead — it creates an isolated environment while keepingpipxandseekdbon your PATH (same program).seekdb-cli
Throughout this skill, examples use ; you may substitute everywhere.
seekdbseekdb-cliEmbedded vs remote: The default local store uses embedded mode (pyseekdb). That requires Linux (glibc ≥ 2.28) or macOS 15+; on other OSes, connect with a remote DSN: .
seekdb --dsn "seekdb://user:pass@host:port/db" ...Connection
DSN resolution (highest priority wins):
- on the CLI (must appear before the subcommand)
--dsn - environment variable
SEEKDB_DSN - in the current working directory (
.envline)SEEKDB_DSN=... ~/.seekdb/config.env- Default
embedded:~/.seekdb/seekdb.db
With no config, the default embedded path applies — you can run commands directly. If the user gives a specific DSN, pass it with :
--dsnbash
# Remote mode
seekdb --dsn "seekdb://user:pass@host:port/db" schema tables
# Remote with TLS (query string on the URL; encode special characters in user/password)
# tls=skip-verify — encrypted, no certificate verification (common for self-signed servers)
seekdb --dsn "seekdb://user:pass@host:2881/db?tls=skip-verify" status
# tls=required — encrypted with default OS CA verification
seekdb --dsn "seekdb://user:pass@host:2881/db?tls=required" sql "SELECT 1"
# Embedded mode (path is a data directory, created if missing; not a single SQLite file)
seekdb --dsn "embedded:./seekdb.db" status
seekdb --dsn "embedded:~/.seekdb/seekdb.db?database=mydb" sql "SELECT 1"DSN formats:
- Remote:
seekdb://user:pass@host:port/db - Remote + TLS: append (or the same values via MySQL-style
?tls=skip-verify|required|verify-ca|verify-identity, e.g.sslmode=,REQUIRED). Optional query params:VERIFY_CA,ssl_ca,ssl_cert,ssl_key.ssl_key_password - Embedded: (default logical database name:
embedded:<path>[?database=<db>])test
Self-Description for AI Agents
Run to get a structured JSON guide of all commands, recommended workflow, safety features, and output format. Execute this once to learn the full CLI.
seekdb ai-guidebash
seekdb ai-guideRecommended Workflow
SQL Database Exploration
1. seekdb schema tables → list all tables (name, column count, row count)
2. seekdb schema describe <table> → get column names, types, indexes, comments
3. seekdb table profile <table> → get data statistics (null ratios, distinct, min/max, top values)
4. seekdb relations infer → infer JOIN relationships between tables
5. seekdb sql "SELECT ... LIMIT N" → execute SQL with explicit LIMITVector Collection Workflow
1. seekdb collection list → list all collections
2. seekdb collection info <name> → get collection details and preview
3. seekdb query <collection> --text "..." → search (default: hybrid = semantic + fulltext)Command Reference
seekdb sql
Execute SQL statements. Default is read-only mode.
bash
# Read query
seekdb sql "SELECT id, name FROM users LIMIT 10"
# Read from file
seekdb sql --file query.sql
# Pipe or redirect (stdin read automatically when not a TTY; --stdin is optional)
echo "SELECT 1" | seekdb sql
# Explicit stdin (e.g. redirect into the command)
seekdb sql --stdin < query.sql
# Include table schema in output
seekdb sql "SELECT * FROM orders LIMIT 5" --with-schema
# Disable large-field truncation
seekdb sql "SELECT content FROM articles LIMIT 1" --no-truncate
# Write operation (requires --write flag)
seekdb sql --write "INSERT INTO users (name) VALUES ('Alice')"
seekdb sql --write "UPDATE users SET name = 'Bob' WHERE id = 1"
seekdb sql --write "DELETE FROM users WHERE id = 3"Output format:
json
{"ok": true, "columns": ["id", "name"], "rows": [{"id": 1, "name": "Alice"}], "affected": 0, "time_ms": 12}seekdb schema tables
bash
seekdb schema tablesjson
{"ok": true, "data": [{"name": "users", "columns": 5, "rows": 1200}, {"name": "orders", "columns": 8, "rows": 50000}]}seekdb schema describe
bash
seekdb schema describe ordersjson
{"ok": true, "data": {"table": "orders", "comment": "Order table", "columns": [{"name": "id", "type": "int", "comment": "Order ID"}, {"name": "status", "type": "varchar(20)", "comment": "0=pending, 1=paid"}], "indexes": ["PRIMARY(id)", "idx_status(status)"]}}seekdb schema dump
bash
seekdb schema dumpReturns all DDL statements.
CREATE TABLEseekdb table profile
Generate statistical summary of a table without returning raw data. Helps understand data distribution before writing SQL.
bash
seekdb table profile <table>json
{"ok": true, "data": {
"table": "orders",
"row_count": 50000,
"columns": [
{"name": "id", "type": "int", "null_ratio": 0, "distinct": 50000, "min": 1, "max": 50000},
{"name": "user_id", "type": "int", "null_ratio": 0, "distinct": 1200, "min": 1, "max": 1500},
{"name": "amount", "type": "decimal(10,2)", "null_ratio": 0.02, "min": 0.5, "max": 9999.99},
{"name": "status", "type": "varchar(20)", "null_ratio": 0, "distinct": 4, "top_values": ["paid", "pending", "refunded", "cancelled"]},
{"name": "created_at", "type": "datetime", "null_ratio": 0, "min": "2024-01-01", "max": "2026-03-10"}
],
"candidate_join_keys": ["user_id"],
"candidate_time_columns": ["created_at"]
}}seekdb relations infer
Infer JOIN relationships between tables by analyzing column name patterns (e.g., → ) and type compatibility.
user_idusers.idbash
# Infer all table relationships
seekdb relations infer
# Infer for a specific table only
seekdb relations infer --table ordersjson
{"ok": true, "data": [
{"from": "orders.user_id", "to": "users.id", "confidence": "high"},
{"from": "orders.product_id", "to": "products.id", "confidence": "high"},
{"from": "order_items.order_id", "to": "orders.id", "confidence": "high"}
]}seekdb collection list
bash
seekdb collection listjson
{"ok": true, "data": [{"name": "docs", "count": 1500}, {"name": "faq", "count": 200}]}seekdb collection create
bash
seekdb collection create my_docs --dimension 384 --distance cosine
seekdb collection create my_docs -d 768 --distance l2Options: / (default: 384), cosine | l2 | ip (default: cosine).
--dimension-d--distanceseekdb collection delete
bash
seekdb collection delete my_docsseekdb collection info
bash
seekdb collection info my_docsjson
{"ok": true, "data": {"name": "my_docs", "count": 1500, "dimension": 384, "distance": "cosine", "preview": {"ids": ["doc1", "doc2"], "documents": ["Hello world", "Test doc"], "metadatas": [{"category": "test"}, {}]}}}dimensiondistanceseekdb query
Search a collection using hybrid (default), semantic (vector), or fulltext mode.
bash
# Hybrid search (default: semantic + fulltext, RRF ranking)
seekdb query my_docs --text "how to deploy seekdb"
# Semantic (vector) only
seekdb query my_docs --text "how to deploy seekdb" --mode semantic
# Fulltext search
seekdb query my_docs --text "deployment guide" --mode fulltext
# With metadata filter
seekdb query my_docs --text "performance tuning" --where '{"category": "tech"}'
# Limit results (--limit or -n, default: 10)
seekdb query my_docs --text "seekdb" -n 5json
{"ok": true, "data": {"results": [
{"id": "doc1", "score": 0.92, "document": "How to deploy seekdb...", "metadata": {"category": "tech"}},
{"id": "doc2", "score": 0.85, "document": "seekdb performance tuning...", "metadata": {"category": "tech"}}
], "count": 2}, "time_ms": 35}seekdb get
Retrieve documents from a collection by IDs or metadata filter.
bash
# Get by IDs
seekdb get my_docs --ids "doc1,doc2"
# Get by metadata filter (--limit or -n, default: 10)
seekdb get my_docs --where '{"category": "tech"}' -n 20seekdb add
Add data to a collection. Exactly one source is required: , , or . The collection is auto-created if it does not exist.
--file--stdin--databash
# From file (JSON array, JSONL, or CSV)
seekdb add my_docs --file data.jsonl
seekdb add my_docs --file articles.csv --vectorize-column content
# Inline: single object or array
seekdb add my_docs --data '{"id":"1","document":"Hello world","metadata":{"source":"cli"}}'
seekdb add my_docs --data '[{"id":"a","document":"Doc A"},{"id":"b","document":"Doc B"}]'
# From stdin (JSON array or JSONL; use with pipes)
echo '{"id":"1","document":"from pipe"}' | seekdb add my_docs --stdin
some_script | seekdb add my_docs --stdinRecord format: Each record may have (optional), // (text to vectorize), and any other fields become metadata. If is present, it is used directly.
iddocumenttextcontentembeddingseekdb export
Export collection data to a file.
bash
seekdb export my_docs --output backup.json
seekdb export my_docs --output backup.jsonl -n 5000Options: (required), / (default: 10000).
--output--limit-nseekdb ai model list
List AI models registered in the database (from / DBMS_AI_SERVICE). Works in both remote and embedded mode.
DBA_OB_AI_MODELSbash
seekdb ai model listjson
{"ok": true, "data": [{"name": "my_llm", "type": "completion", "model_name": "THUDM/GLM-4-9B-0414", "model_id": 1}]}seekdb ai model create
Register an AI model via . Create an endpoint separately to use it for completion.
DBMS_AI_SERVICE.CREATE_AI_MODELbash
seekdb ai model create my_llm --type completion --model "THUDM/GLM-4-9B-0414"
seekdb ai model create my_embed --type dense_embedding --model "BAAI/bge-m3"
seekdb ai model create my_rerank --type rerank --model "<rerank_model>"Types: , , .
completiondense_embeddingrerankseekdb ai model delete
Drop an AI model. Drop any endpoints that use it first.
bash
seekdb ai model delete my_llmseekdb ai model endpoint create / delete
Create or drop an endpoint that binds an AI model to a URL and API key (so the database can call the model).
bash
seekdb ai model endpoint create my_ep my_llm \
--url "https://api.siliconflow.cn/v1/chat/completions" \
--access-key "<YOUR_API_KEY>" \
--provider siliconflow
seekdb ai model endpoint delete my_epSupported values:
--provider| Provider | Vendor |
|---|---|
| SiliconFlow (OpenAI-compatible) |
| OpenAI |
| DeepSeek (OpenAI-compatible) |
| Alibaba Cloud (OpenAI-compatible) |
| Alibaba Cloud DashScope |
| Tencent Hunyuan (OpenAI-compatible) |
Common values (use the specific interface URL, not the base URL):
--url| Vendor | completion | embedding | rerank |
|---|---|---|---|
| SiliconFlow | | | |
| DeepSeek | | — | — |
| Alibaba (OpenAI) | | | — |
| Tencent Hunyuan | | | — |
Full parameter spec: CREATE_AI_MODEL_ENDPOINT
seekdb ai complete
Run text completion using the database function. Requires a registered completion model and an endpoint. Supported in both remote and embedded mode.
AI_COMPLETEbash
seekdb ai complete "Summarize this table structure" --model my_llmjson
{"ok": true, "data": {"model": "my_llm", "response": "The table has..."}, "time_ms": 1200}seekdb ai-guide
Output a structured JSON guide for AI Agents containing all commands, parameters, workflow, and safety rules. Execute once to learn the full CLI.
bash
seekdb ai-guideseekdb status
bash
seekdb statusReturns CLI version, server version, database name, and connectivity.
Safety Features
Row Protection
Queries without are automatically probed. If result exceeds 100 rows, execution is blocked:
LIMITjson
{"ok": false, "error": {"code": "LIMIT_REQUIRED", "message": "Query returns more than 100 rows. Please add LIMIT to your SQL."}}Action: Add an explicit clause and retry.
LIMITWrite Protection
Write operations (INSERT/UPDATE/DELETE) are blocked by default:
json
{"ok": false, "error": {"code": "WRITE_NOT_ALLOWED", "message": "Write operations require --write flag."}}Action: Add flag to enable write operations.
--writeEven with , / without a clause are blocked.
--writeDELETEUPDATEWHEREError Auto-Correction
On SQL errors, the CLI automatically attaches schema hints:
Column not found → returns the table's column list and indexes:
json
{"ok": false, "error": {"code": "SQL_ERROR", "message": "Unknown column 'username'"}, "schema": {"table": "users", "columns": ["id", "name", "email"], "indexes": ["PRIMARY(id)"]}}Table not found → returns available table names:
json
{"ok": false, "error": {"code": "SQL_ERROR", "message": "Table 'user' does not exist"}, "schema": {"tables": ["users", "orders", "products"]}}Action: Use the schema info to correct the SQL and retry.
Large Field Truncation
TEXT/BLOB fields are truncated to 200 characters by default, with original length noted:
json
{"content": "First 200 characters of content...(truncated, 8520 chars)"}Use to get full content when needed.
--no-truncateSensitive Field Masking
Columns matching sensitive patterns are automatically masked:
| Pattern | Example Output |
|---|---|
| phone/mobile/tel | |
| |
| password/secret/api_key | |
| id_card / national_id / similar | |
Output Formats
Default is JSON. Switch with (global option; must appear before the subcommand):
--formatbash
seekdb --format table sql "SELECT id, name FROM users LIMIT 5"
seekdb --format csv sql "SELECT id, name FROM users LIMIT 5"
seekdb --format jsonl sql "SELECT id, name FROM users LIMIT 5"All formats now work with non-row data (e.g., , ). CSV and JSONL will auto-detect list-of-dict data in the field.
schema tablescollection listdataExit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Business error (SQL error, connection error, etc.) |
| 2 | Usage error (missing arguments, invalid options) |
Operation Logging
All commands are logged to for audit (SQL invocations include a redacted field when applicable):
~/.seekdb/sql-history.jsonlsqljson
{"ts": "2026-03-12T14:23:01", "command": "sql", "sql": "SELECT id FROM users LIMIT 10", "ok": true, "rows": 10, "time_ms": 12}