hotdata-cli README

项目的 README,来自 github.com/hotdata-dev/hotdata-cli。合并为一个 markdown 文件:README.md。

Hotdata
Hotdata CLI
Command line interface for Hotdata.

release build coverage


Load your data into a Hotdata database, then query, join, and search it with plain SQL. Data can come from files on your machine, a URL, or an external source such as Postgres, S3, Iceberg, Kafka, or one of ~150 API services.

📖 Full documentation: hotdata.dev/docs

Install

curl -fsSL https://hotdata.dev/install | sh

That's it. The installer uses Homebrew if you have it (brew install hotdata-dev/tap/cli) and also installs the Hotdata skill for AI coding agents such as Claude Code. You can also download a binary from Releases.

The CLI tells you when a new version is out; upgrade with hotdata manage upgrade.

Quickstart

# 1. Log in (or create an account with: hotdata auth register)
hotdata auth login

# 2. Create a database and make it your current one
hotdata databases create --catalog demo
hotdata databases use demo

# 3. Load some data
hotdata databases load --catalog demo --table trips \
  --url https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2024-01.parquet

# 4. Query it
hotdata query "SELECT count(*) FROM demo.public.trips"

Tables are addressed as catalog.schema.table. Here the catalog is demo and the default schema is public. The examples below build on this demo database. For a longer walkthrough, see the quick start guide.

Load your data

From a file or URL (CSV, JSON, or Parquet). Point --file at your own file, or --url at one online:

hotdata databases load --catalog demo --table my_table --file ./my-data.csv

A load replaces the table. To add rows instead, use --mode append:

hotdata databases load --catalog demo --table my_table --file ./more-data.csv --mode append

To change existing rows by key, use --mode update, --mode delete, or --mode upsert with --key <column>.

From an external source such as Postgres, MySQL, S3, GCS, Iceberg, Kafka, or an API service: first save the connection details as a datasource, then create an ingest that copies data into your database once or on a schedule.

hotdata ingest sources types        # see what you can connect to
hotdata ingest sources add          # save a datasource (you'll be prompted)
hotdata ingest create --source "prod postgres" --table orders --database-id <database-id>
hotdata ingest list                 # check on your ingests

More in the docs: loading data and importing from external sources.

Query

hotdata databases tables list                       # what can I query?
hotdata databases tables show demo.public.trips     # columns and types
hotdata query "SELECT * FROM demo.public.trips LIMIT 10"

SQL is PostgreSQL-style. Add -o json or -o csv to change the output format. If you prefer another dialect, pass --dialect duckdb, postgres, snowflake, or clickhouse and the query is translated for you.

You can also write with SQL. INSERT, CREATE TABLE, CREATE TABLE AS, and DROP TABLE work on your current database's tables (your API key needs the write permission):

hotdata query "CREATE TABLE events (id BIGINT, kind TEXT)"
hotdata query "INSERT INTO events VALUES (1, 'signup'), (2, 'login')"

UPDATE and DELETE aren't supported in SQL yet; use databases load with --mode update, --mode delete, or --mode upsert instead.

Long-running queries finish in the background. The CLI prints an id you can check with hotdata query status <id>.

Column names are case-sensitive: wrap names with capital letters in double quotes, like "PULocationID". See the SQL reference for the supported syntax and functions.

Join across databases

Keep reference data in its own database and attach it wherever you need it. No data is copied. For example, load NYC's taxi zone names into a zones database, attach it to demo, and find the busiest pickup zones:

hotdata databases create --catalog zones
hotdata databases load --catalog zones --table zones \
  --url https://d37ci6vzurychx.cloudfront.net/misc/taxi_zone_lookup.csv
hotdata databases attach zones

hotdata query 'SELECT z."Zone", count(*) AS trips
               FROM demo.public.trips t
               JOIN zones.public.zones z ON z."LocationID" = t."PULocationID"
               GROUP BY z."Zone" ORDER BY trips DESC LIMIT 5'

Attached tables are read-only. hotdata databases detach zones removes the link without deleting anything.

Build a search index on a column, then search it. Using the zones table from above:

hotdata search create zone_names --type text --from zones.public.zones --column Zone
hotdata search "airport" --index zone_names -d zones

That returns JFK, LaGuardia, and Newark airports. An index lives in the same database as its table, so pass -d when that isn't your current database.

Rollups

A rollup keeps a table pre-aggregated by time, so dashboards and reports that aggregate a large, time-stamped table over days or weeks stay fast. You keep querying the table; an aggregate query the rollup can answer reads it instead.

hotdata rollups create public.requests --time-column ts --bucket 1h \
  --dimensions region,status \
  --measure count --measure numeric:bytes --measure approx_percentile:latency_ms

hotdata query "SELECT date_trunc('day', ts) AS day, region, count(*), avg(bytes)
               FROM public.requests GROUP BY 1, 2"
# ... [rollup: used]

create waits for the rollup to build; pass --async to return right away. hotdata query tells you whether a rollup answered: used, not_matched (the query's shape doesn't fit it), or not_ready (still building, or it needs hotdata rollups rebuild).

Creating a rollup restricts writes to its table: rows older than the window (one hour by default; change it with hotdata rollups window) can no longer be changed or deleted. Appends always work. See the rollups guide for the details.

Your current workspace and database

Most commands run against your current workspace and database, so you don't have to name them every time.

Your choice is saved on this machine and survives logging out and back in.

Scripts, CI, and AI agents

Claude Code plugin

To get the agent skill through Claude Code's plugin manager instead, which updates it with each release:

/plugin marketplace add hotdata-dev/claude-plugins
/plugin install hotdata-cli@hotdata

Self-hosted marketplaces don't auto-update by default. To get each release automatically, open /plugin, go to Marketplaces, select hotdata, and choose Enable auto-update. Otherwise run /plugin marketplace update hotdata when a new version ships.

Use either the plugin or the installer's skill, not both: if you installed the CLI with the script above, install it with HOTDATA_NO_SKILLS=1 or Claude Code will list the skill twice.

For what the plugin runs, sends, and fetches, see plugin/README.md.

Getting help

Reference

All commands
Command What it does
auth login Log in via browser
auth register Create a new account via browser (GitHub OAuth; --email for email + password)
auth logout Remove authentication for a profile
auth status Show authentication status
workspaces list List all workspaces
workspaces use Switch the current workspace (remembered across logins)
databases list List instant databases in the workspace
databases count Count instant databases in the workspace
databases show Show details for an instant database
databases create Create a new instant database
databases fork Fork a database into a new, independent database
databases lineage Show a database's whole fork family tree
databases attach Attach another database so its tables are queryable
databases detach Detach a previously attached database
databases use Switch the current database (remembered across logins)
databases unset Clear the current database
databases remove Delete a database and all its tables
databases load Load a csv/json/parquet file or saved result into a table (--mode replace|append|delete|update|upsert)
databases tables add Declare a table with its key and storage layout
databases tables list List tables in a database
databases tables show Show column definitions for a table
databases tables load Same as databases load, addressed by database instead of catalog
databases tables remove Delete a table from a database
databases context list List named contexts in a database
databases context show Print context content to stdout
databases context pull Download context to ./<NAME>.md
databases context push Upload ./<NAME>.md as named context
databases query Execute a SQL query against a database
databases query status Check a running query and retrieve results
databases queries list List query runs
databases results get Show a stored query result by ID
databases results list List stored query results
query "<sql>" Execute a SQL query (shortcut for databases query)
query status Check a running query and retrieve results
jobs list List background jobs (active by default)
jobs <id> Show one background job
ingest create Create a load definition
ingest list List the ingests in the workspace
ingest show Show one ingest: state, selector, destination, schedule
ingest pause Stop an ingest (cancel the active run and future runs)
ingest resume Clear a stop and let the schedule dispatch again
ingest schedule Change when a scheduled/continuous ingest runs next
ingest logs List the runs of one ingest
ingest run Show one run: status, snapshots, timings
ingest remove Delete an ingest and release its destination table
ingest sources test Check a config and credentials without creating anything
ingest sources add Create a datasource and its first config version
ingest sources list List the datasources in the workspace
ingest sources show Show one datasource: state, config, discovery
ingest sources update-config Append a config version (rotate credentials)
ingest sources remove Delete a datasource
ingest sources types Browse the catalog of source types
ingest sources fields Show the fields a source family accepts
search "<text>" --index <name> Run a full-text or vector search against an index
search create Create a search index over a table column
search list List search indexes
search show Show one search index by name
search remove Remove a search index by name
search embeddings list List embedding providers
search embeddings show Show one embedding provider
search embeddings add Create a new embedding provider
search embeddings update Update an embedding provider
search embeddings remove Delete an embedding provider
rollups create Create a rollup on a table and wait for it to build
rollups list List the rollups in a database
rollups show Show one rollup: what it keeps, its status, its build progress
rollups rebuild Build a rollup again (after its table was replaced, or a failed build)
rollups window Set how long a table's rows stay editable after their time
rollups remove Remove a rollup; the table does not change
manage usage Show workspace usage: queries, bytes scanned, stored bytes
manage completions Generate shell completions (bash, zsh, fish)
manage upgrade Upgrade the CLI to the latest release
manage skills install Install/update the agent skill into agent directories
manage skills status Show the agent skill's installation status
manage skills list List installed skills (alias for status)
support report File a support ticket with the Hotdata team
Configuration and environment variables

Config lives at ~/.hotdata/config.yml.

Variable Description Default
HOTDATA_API_KEY API key (overrides config file; also read from .env)
HOTDATA_WORKSPACE Lock every command to one workspace (workspaces use refuses while set)
HOTDATA_DATABASE Database to use when -d/--database is not given; overrides the saved current database
HOTDATA_NO_UPDATE_CHECK Skip the interactive new-release check
HOTDATA_CONFIG_DIR Where config and credentials live ~/.hotdata
HOTDATA_UPLOAD_CONCURRENCY Parallel parts for multipart uploads in databases load 12
HOTDATA_API_URL API base URL https://api.hotdata.dev/v1
HOTDATA_APP_URL App URL for browser login https://app.hotdata.dev

An API key is taken from, in order of priority: --api-key, then HOTDATA_API_KEY, then the config file.

Installer options: HOTDATA_NO_BREW=1 skips Homebrew, HOTDATA_NO_SKILLS=1 skips the agent skill. Tab completion: hotdata manage completions bash|zsh|fish.

Development

cargo build && cargo test

Build from source with cargo install --path . (requires Rust). Release process: docs/RELEASING.md.

hotdata-cli (hotdata-dev/hotdata-cli)

正在搜索数据库…

这是什么?Hotdata CLI 是一个命令行客户端,让你在一个地方查询、搜索和联接数据——外部数据库、API、云存储、Iceberg 目录和上传的文件——只需使用普通 SQL 和少量命令。
这是本地数据库引擎,还是云服务的 CLI?它是一个 CLI 客户端,不是本地数据库:它会创建一个由 HotData 托管的“即时数据库”(instant database),你的 SQL 查询实际上是在服务端针对它运行的。
我怎么让它跑起来?从项目的 GitHub Releases 获取预构建的二进制文件,然后创建一个即时数据库、把数据加载进去,并用 PostgreSQL 方言的 SQL 查询它——这就是其余一切功能赖以构建的核心循环。
使用这个 CLI 需要 HotData 账户吗?需要——你用 `auth login` 通过浏览器进行身份验证(包括 GitHub OAuth),或者通过 `--api-key` 或 HOTDATAAPIKEY 环境变量传入 API 密钥;无需在本地设置任何数据库引擎。
如果我运行一个又大又慢的查询会怎样?长查询是异步运行的:CLI 会输出一个 queryrunid,你用 `query status` 轮询它,退出码会告诉你查询是已完成、失败、仍在运行,还是已完成但只返回了截断的预览。
它能在 Windows、Mac 和 Linux 上运行吗?可以,它是一个 Rust CLI,通过 GitHub Releases 以跨平台二进制文件的形式分发,并为 bash、zsh 和 fish 提供命令补全支持。
我上传的数据最终去了哪里?上传的文件和接入的数据会进入云中由 HotData 托管的“即时数据库”,即使是跨数据库联接也是针对该托管服务运行,而不是在本地。
我能在不复制数据的情况下联接两个不同即时数据库的数据吗?可以——你可以挂载另一个即时数据库(只读)并直接与自己的表一起查询它的表;卸载只是移除可见性,不会删除任何数据。
向量/语义搜索需要我自己的嵌入模型吗?不需要,向量搜索会在服务端自动为索引列和查询生成嵌入,无需嵌入密钥;不过你也可以通过 `search embeddings add` 使用自己的模型。
Claude Code 这类 AI 编程智能体能直接使用这个 CLI 吗?可以——`hotdata manage skills install` 会安装内置的 Markdown 操作手册,教智能体使用完整的 CLI;`databases context push` 则把你的数据模型作为一份映射共享出来,人和智能体都可以对照它进行查询。
除文件上传外,我还能从哪些数据源导入数据?你可以通过数据源和已保存、可调度的接入定义,从 Postgres/MySQL、S3/GCS 存储桶、Iceberg 目录、Kafka 以及大约 150 个 API 服务接入数据。
大小
2.3 MB
星标
1.8K
时长
9个月
提交 · 90 天