← 返回 Skills 市场
wenbingyu

Hologres Cli

作者 francis · GitHub ↗ · v0.2.0 · MIT-0
cross-platform ⚠ suspicious
33
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install hologres-cli
功能描述
AI-agent-friendly Hologres CLI with safety guardrails and structured JSON output. Use for database operations, schema inspection, SQL execution, data import/...
使用说明 (SKILL.md)

Hologres CLI

AI-agent-friendly command-line interface for Hologres with safety guardrails and structured JSON output.

Installation

# Requires Python 3.11+
pip install hologres-cli

# Or install a specific version
pip install hologres-cli==0.2.0

Configuration

Profile-based configuration stored in ~/.hologres/config.json.

# Interactive setup wizard
hologres config

# Or set values directly
hologres config set region_id cn-hangzhou
hologres config set instance_id hgprecn-cn-xxx
hologres config set database mydb

Profile resolution priority: --profile \x3Cname> flag > current profile > error (prompts to run hologres config).

Quick Start

pip install hologres-cli
hologres config                                   # Interactive setup
hologres status                                    # Check connection
hologres schema tables                             # List tables
hologres sql run "SELECT * FROM orders LIMIT 10"   # Query data
hologres --profile prod status                     # Use specific profile
hologres dt list                                   # List Dynamic Tables

Core Commands

Command Description
hologres status Check connection status
hologres instance \x3Cname> Query instance version/connections
hologres warehouse [name] List or query warehouses
hologres schema tables List all tables
hologres schema describe \x3Ctable> Show table structure
hologres schema dump \x3Cschema.table> Export DDL
hologres schema size \x3Cschema.table> Get table storage size
hologres table list [--schema S] List all tables
hologres table create -n TABLE -c COLS [options] [--dry-run] Create a table (supports logical partition V3.1+)
hologres table dump \x3Cschema.table> Export DDL for a table
hologres table show \x3Ctable> Show table structure (columns, types, nullable, defaults, primary key, comments)
hologres table size \x3Cschema.table> Get table storage size
hologres table properties \x3Ctable> Show Hologres-specific table properties (orientation, distribution_key, clustering_key, TTL, etc.)
hologres table drop \x3Ctable> [--if-exists] [--cascade] --confirm Drop a table (dry-run by default)
hologres table truncate \x3Ctable> --confirm Truncate (empty) a table (dry-run by default)
hologres table alter TABLE [options] [--dry-run] Alter table properties (add column, rename, TTL, etc.)
hologres partition list --table \x3Ctable> List partitions of a logical partition table
hologres partition create --table \x3Ctable> Create partition (no-op for logical tables, returns notice)
hologres partition drop --table \x3Ctable> --partition VALUE --confirm Drop partition (deletes partition data)
hologres partition alter --table \x3Ctable> --partition \x3Cvalue> --set \x3Ckey=value> [--dry-run] Alter partition properties (keep_alive, storage_mode, generate_binlog)
hologres partition alter --table \x3Ctable> --partition \x3Cvalue> --set \x3Ckey=value> [--dry-run] Alter partition properties (keep_alive, storage_mode, generate_binlog)
hologres view list [--schema S] List all views
hologres view show \x3Cview> Show view definition and structure
hologres extension list List installed extensions
hologres extension create \x3Cname> [--if-not-exists] Create (install) a database extension
hologres guc show \x3Cparam> Show current value of a GUC parameter
hologres guc set \x3Cparam> \x3Cvalue> Set GUC parameter at database level (persistent)
hologres sql run "\x3Cquery>" Execute read-only SQL
hologres sql run --write "\x3Cdml>" Execute write SQL
hologres sql explain "\x3Cquery>" Show SQL execution plan
hologres data export \x3Ctable> -f out.csv [-q \x3Cquery>] [-d \x3Cdelimiter>] Export to CSV
hologres data import \x3Ctable> -f in.csv [-d \x3Cdelimiter>] [--truncate] Import from CSV
hologres data count \x3Ctable> [-w \x3Cwhere>] Count rows
hologres history [-n \x3Ccount>] Show command history
hologres ai-guide Generate AI agent guide
hologres ai gen "\x3Cprompt>" [--model] Generate text using AI function
hologres ai image-gen "\x3Cprompt>" -o volume://vol/path [options] Generate images to OSS volume using AI function
hologres ai t2v "\x3Cprompt>" -o volume://vol/path [options] Generate video from text (text-to-video)
hologres ai i2v "\x3Cprompt>" --img-url \x3Curl|local_file> -o volume://vol/path [options] Generate video from first-frame image (image-to-video)
hologres ai r2v "\x3Cprompt>" --reference-url \x3Curl|local_file> -o volume://vol/path [options] Generate video from reference images (reference-to-video)
hologres ai video-edit "\x3Cprompt>" --video \x3Curl|local_file> -o volume://vol/path [options] Edit video with text instructions
hologres volume create \x3Cname> --endpoint \x3Cep> --root \x3Croot> --rolearn \x3Carn> --access-key \x3Cak> --access-secret \x3Csk> Create a local volume config (also creates OSS directory placeholder)
hologres volume list List all volumes in current profile
hologres volume delete \x3Cname> Delete a volume config
hologres volume list-files --volume \x3Cname> [--prefix P] [--max-count N] [--net internet|intranet] List files in volume
hologres volume delete-file --volume \x3Cname> --file \x3Cpath> [--confirm] [--net internet|intranet] Delete file from volume (dry-run by default)
hologres volume download-file --volume \x3Cname> --file \x3Cpath> -d \x3Cdir> [--net internet|intranet] Download file from volume
hologres volume upload-file --volume \x3Cname> --local-file \x3Cpath> --target-file \x3Cpath> [--net internet|intranet] Upload file to volume
hologres volume view volume://\x3Cname>/path/file [--net internet|intranet] Download file to temp dir and open with system viewer
hologres model list [--task T] [--model-type T] [--search S] List registered external AI models
hologres model catalog [--task T] [--search S] List supported AI model types from the bundled catalog (no DB connection)
hologres model create --name N --type T --api-key K [--config J] [--dry-run] Register an external AI model via add_external_model()
hologres model delete \x3Cmodel_name> [--confirm] Delete a registered external AI model (dry-run by default)

Dynamic Table Commands (V3.1+)

Full lifecycle management for Hologres Dynamic Tables.

Command Description
hologres dt create Create a Dynamic Table
hologres dt list List all Dynamic Tables
hologres dt show \x3Ctable> Show Dynamic Table properties
hologres dt ddl \x3Ctable> Show DDL (CREATE statement)
hologres dt lineage \x3Ctable> Show dependency lineage
hologres dt lineage --all Show lineage for all DTs
hologres dt storage \x3Ctable> Show storage details
hologres dt state-size \x3Ctable> Show state table size (incremental)
hologres dt refresh \x3Ctable> Trigger manual refresh
hologres dt alter \x3Ctable> Alter DT properties
hologres dt drop \x3Ctable> Drop DT (dry-run by default)
hologres dt convert [table] Convert V3.0 → V3.1 syntax

dt create

# Minimal
hologres dt create -t my_dt --freshness "10 minutes" \
  -q "SELECT col1, SUM(col2) FROM src GROUP BY col1"

# With partitioning and serverless
hologres dt create -t ads_report --freshness "5 minutes" --refresh-mode auto \
  --logical-partition-key ds --partition-active-time "2 days" \
  --partition-time-format YYYY-MM-DD \
  --computing-resource serverless --serverless-cores 32 \
  -q "SELECT repo_name, COUNT(*) AS events, ds FROM src GROUP BY repo_name, ds"

# Incremental refresh
hologres dt create -t tpch_q1 --freshness "3 minutes" --refresh-mode incremental \
  -q "SELECT l_returnflag, l_linestatus, COUNT(*) FROM lineitem GROUP BY 1,2"

# Dry-run (preview SQL without executing)
hologres dt create -t my_dt --freshness "10 minutes" -q "SELECT 1" --dry-run

Key create options:

Option Description
-t, --table Table name [schema.]table (required)
-q, --query SQL query for data definition (required)
--freshness Data freshness target, e.g. "10 minutes" (required)
--refresh-mode auto / full / incremental
--auto-refresh/--no-auto-refresh Enable/disable auto refresh
--cdc-format stream (default) / binlog
--computing-resource local / serverless / \x3Cwarehouse>
--serverless-cores Serverless computing cores
--logical-partition-key Partition column for logical partition
--partition-active-time Active partition window, e.g. "2 days"
--partition-time-format Partition key format, e.g. YYYY-MM-DD
--orientation column / row / row,column
--distribution-key Distribution key columns
--clustering-key Clustering key with sort order
--event-time-column Event time column (Segment Key)
--ttl Data TTL in seconds
--refresh-guc GUC params for refresh (repeatable)
--dry-run Preview SQL without executing

dt list / show / ddl

hologres dt list                     # List all DTs with refresh info
hologres dt show public.my_dt        # Show all properties
hologres dt ddl public.my_dt         # Show CREATE statement
hologres dt list -f table            # Table format output

dt lineage

hologres dt lineage public.my_dt     # Single table lineage
hologres dt lineage --all            # All DTs lineage
hologres dt lineage my_dt -f table   # Table format

base_table_type: r=table, v=view, m=materialized view, f=foreign table, d=Dynamic Table.

dt storage / state-size

hologres dt storage public.my_dt      # Storage breakdown
hologres dt state-size public.my_dt   # State table size (incremental DTs)

dt refresh

hologres dt refresh my_dt
hologres dt refresh my_dt --overwrite --partition "ds = '2025-04-01'" --mode full
hologres dt refresh my_dt --dry-run

dt alter

hologres dt alter my_dt --freshness "30 minutes"
hologres dt alter my_dt --no-auto-refresh
hologres dt alter my_dt --refresh-mode full --computing-resource serverless
hologres dt alter my_dt --refresh-guc timezone=GMT-8:00 --dry-run

dt drop

hologres dt drop my_dt               # Dry-run by default (safety)
hologres dt drop my_dt --confirm     # Actually drop
hologres dt drop my_dt --if-exists --confirm

dt convert (V3.0 → V3.1)

hologres dt convert my_old_dt          # Convert single table
hologres dt convert --all              # Convert all V3.0 tables
hologres dt convert my_old_dt --dry-run

Output Formats

Partition Management

# List partitions
hologres partition list -t public.logs

# Drop a partition
hologres partition drop -t my_table --partition "2025-04-01" --confirm

# Alter partition properties
hologres partition alter -t public.logs --partition "ds=2025-03-16" --set "keep_alive=TRUE"
hologres partition alter -t my_table --partition "ds=2025-03-16" --set "keep_alive=TRUE" --set "storage_mode=hot" --dry-run

Output Formats

hologres -f json schema tables    # JSON (default)
hologres -f table schema tables   # Human-readable table
hologres -f csv schema tables     # CSV
hologres -f jsonl schema tables   # JSON Lines

Response Structure

// Success
{"ok": true, "data": {"rows": [...], "count": 10}}

// Error
{"ok": false, "error": {"code": "ERROR_CODE", "message": "..."}}

Safety Features

0. Default Session GUC Protection

All connections automatically set safety GUCs upon creation:

  • SET hg_experimental_enable_adaptive_execution = on — Enables adaptive execution to prevent OOM
  • SET hg_computing_resource = 'serverless' — Routes queries to the serverless computing pool

These are applied transparently at the connection layer; no user action needed.

1. Row Limit Protection

Queries without LIMIT returning >100 rows fail with LIMIT_REQUIRED.

# Will fail if >100 rows
hologres sql run "SELECT * FROM large_table"

# Fix: add LIMIT
hologres sql run "SELECT * FROM large_table LIMIT 50"

# Or disable check
hologres sql run --no-limit-check "SELECT * FROM large_table"

2. Write Protection

Write operations (INSERT, UPDATE, DELETE, DROP, CREATE, ALTER, TRUNCATE, GRANT, REVOKE) require --write flag.

hologres sql run --write "INSERT INTO logs VALUES (1, 'test')"

3. Dangerous Write Blocking

DELETE/UPDATE without WHERE clause are blocked.

# Blocked
hologres sql run --write "DELETE FROM users"

# Must have WHERE
hologres sql run --write "DELETE FROM users WHERE status='inactive'"

Error Codes

Code Description
CONNECTION_ERROR Failed to connect
QUERY_ERROR SQL execution error
LIMIT_REQUIRED Need LIMIT clause
WRITE_GUARD_ERROR Write operation without --write flag
DANGEROUS_WRITE_BLOCKED DELETE/UPDATE without WHERE clause
WRITE_BLOCKED Write operation not allowed
NOT_FOUND Table or resource not found
INVALID_INPUT Invalid identifier or input validation failed
INVALID_ARGS Invalid or missing arguments
NO_CHANGES No properties specified to alter
EXPORT_ERROR Data export failed
IMPORT_ERROR Data import failed
VIEW_NOT_FOUND View not found
OSS_ERROR OSS operation failed (e.g. directory placeholder creation on volume create)

Sensitive Data Masking

Auto-masks by column name pattern:

  • phone/mobile/tel → 138****5678
  • email → j***@example.com
  • password/secret/token → ********

Disable: hologres sql run --no-mask "SELECT * FROM users LIMIT 10"

References

Document Content
commands.md Complete command reference with DT commands
ai-volume-model.md AI generation, volume storage, and model commands
safety-features.md Safety guardrails details

Best Practices

  1. Always use LIMIT for large result sets
  2. Use --dry-run to preview DT SQL before executing
  3. Use --confirm explicitly for destructive operations (table drop, table truncate, dt drop)
  4. Include WHERE clause in DELETE/UPDATE
  5. Use JSON output for automation/scripting
  6. Check hologres status before batch operations
  7. Use hologres dt lineage to understand DT dependencies before altering

SQL Tracking

Set HOLOGRES_SKILL environment variable before calling CLI to tag queries with skill origin:

export HOLOGRES_SKILL=hologres-query-optimizer
hologres sql run "SELECT * FROM orders LIMIT 10"

Queries will appear in hg_query_log with application_name = "hologres-cli/hologres-query-optimizer".

This enables per-skill SQL statistics on the Hologres server:

SELECT
  split_part(application_name, '/', 2) AS skill,
  COUNT(*) AS query_count,
  AVG(duration) AS avg_duration_ms
FROM hologres.hg_query_log
WHERE query_start > now() - interval '1 hour'
  AND application_name LIKE 'hologres-cli/%'
GROUP BY 1
ORDER BY 2 DESC;
安全使用建议
Before installing, verify the hologres-cli package source and pin a reviewed version. Start with a least-privileged Hologres profile, keep config and history files protected, and require explicit confirmation before any write, drop, truncate, import-with-truncate, GUC set, or file upload operation.
能力标签
requires-sensitive-credentials
能力评估
Purpose & Capability
The documented capabilities are coherent with a Hologres CLI: database inspection, SQL execution, import/export, Dynamic Table management, GUC management, AI generation, and OSS volume operations. Several capabilities are high-impact, including writes, drops, truncates, imports with truncate, and persistent parameter changes.
Instruction Scope
The instructions document safety controls such as read-only defaults, --write for DML, dry-run defaults, --confirm for destructive operations, WHERE checks for UPDATE/DELETE, row limits, and masking. Users should still ensure destructive commands and bypass flags are only used on explicit request.
Install Mechanism
The skill is instruction-only with no reviewed install spec and points users to pip install an external hologres-cli package while registry provenance is unknown. Because that external code would handle credentials and database mutations, the provenance gap is material.
Credentials
The requested environment access is mostly proportional to the stated purpose, but it includes database credentials, OSS access keys/secrets, selected local file uploads/downloads, and third-party AI/OSS data flows.
Persistence & Privilege
The skill documents persistent local profile storage in ~/.hologres/config.json, command/SQL audit history in ~/.hologres/sql-history.jsonl, and persistent database-level GUC changes.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install hologres-cli
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /hologres-cli 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.2.0
Version 0.2.0 - Introduced an AI-agent-friendly command-line interface for Hologres with safety guardrails and structured JSON output. - Added profile-based configuration with interactive and direct setup commands. - Provided comprehensive commands for database inspection, schema, tables, partitions, views, extensions, and GUC parameter management. - Included data import/export, command history, and dry-run support for destructive operations. - Implemented full lifecycle management commands for Dynamic Tables (V3.1+ syntax). - Added AI integration features (text, image, and video generation; model management) and local OSS-like volume operations. - Enhanced usability with clear help, dry-run confirmations, and structured output for agent automation.
元数据
Slug hologres-cli
版本 0.2.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Hologres Cli 是什么?

AI-agent-friendly Hologres CLI with safety guardrails and structured JSON output. Use for database operations, schema inspection, SQL execution, data import/... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 33 次。

如何安装 Hologres Cli?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install hologres-cli」即可一键安装,无需额外配置。

Hologres Cli 是免费的吗?

是的,Hologres Cli 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Hologres Cli 支持哪些平台?

Hologres Cli 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Hologres Cli?

由 francis(@wenbingyu)开发并维护,当前版本 v0.2.0。

💬 留言讨论