Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ API key priority (lowest to highest): config file → `HOTDATA_API_KEY` env var
| `auth` | `login`, `status`, `logout` | `login` or bare `auth` opens browser login; `status` / `logout` manage the saved profile |
| `workspaces` | `list`, `set` | Manage workspaces |
| `connections` | `list`, `create`, `refresh`, `new` | Manage connections |
| `databases` | `list`, `create`, `delete`, `tables` | Managed databases (create and load tables via parquet) |
| `tables` | `list` | List tables and columns |
| `datasets` | `list`, `create`, `update` | Manage uploaded datasets |
| `context` | `list`, `show`, `pull`, `push` | Workspace Markdown context (e.g. data model `DATAMODEL`) via the context API |
Expand Down Expand Up @@ -127,6 +128,34 @@ hotdata connections create list <type_name> --format json
hotdata connections create --name "my-conn" --type postgres --config '{"host":"...","port":5432,...}'
```

## Databases

Managed databases are Hotdata-owned catalogs you create and populate yourself (no remote source to sync). Query them with SQL as `database_name.schema.table` — the database name is the connection name.

```sh
hotdata databases list [-w <id>] [-o table|json|yaml]
hotdata databases create --name <name> [--table <table> ...] [--schema public] [-o table|json|yaml]
hotdata databases <name_or_id> [-o table|json|yaml]
hotdata databases delete <name_or_id>

hotdata databases tables list <database> [--schema <name>] [-o table|json|yaml]
hotdata databases tables load <database> <table> --file ./data.parquet [--schema public]
hotdata databases tables load <database> <table> --upload-id <id> [--schema public]
hotdata databases tables delete <database> <table> [--schema public]
```

- `create` registers a managed connection (`source_type: managed`) with no external credentials. Use `--table` to declare tables up front (required before `tables load` on the current API).
- `tables load` uploads a **parquet** file (or uses a staged `upload_id` from `POST /v1/files`) and publishes it as the table generation (`replace` mode).
- For CSV/JSON uploads without a managed database, use `hotdata datasets create` instead (`datasets.main.*`).

Example:

```sh
hotdata databases create --name sales --table orders
hotdata databases tables load sales orders --file ./orders.parquet
hotdata query "SELECT count(*) FROM sales.public.orders"
```

## Tables

```sh
Expand Down
109 changes: 109 additions & 0 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ pub enum Commands {
command: Option<ConnectionsCommands>,
},

/// Managed databases you create and populate with tables (parquet uploads)
Databases {
/// Database name or connection ID (omit to use a subcommand)
name_or_id: Option<String>,

/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w', global = true)]
workspace_id: Option<String>,

/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,

#[command(subcommand)]
command: Option<DatabasesCommands>,
},

/// Manage tables in a workspace
Tables {
#[command(subcommand)]
Expand Down Expand Up @@ -515,6 +532,98 @@ pub enum ConnectionsCreateCommands {
},
}

#[derive(Subcommand)]
pub enum DatabasesCommands {
/// List managed databases in the workspace
List {
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},

/// Create a new managed database
Create {
/// Database name (used as the connection name in SQL: `name.schema.table`)
#[arg(long)]
name: String,

/// Schema for tables declared at create time (default: public)
#[arg(long, default_value = "public")]
schema: String,

/// Table to declare up front (repeatable). Required before load on current API.
#[arg(long = "table")]
tables: Vec<String>,

/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},

/// Delete a managed database and its tables
Delete {
/// Database name or connection ID
name_or_id: String,
},

/// Manage tables inside a managed database
Tables {
#[command(subcommand)]
command: DatabaseTablesCommands,
},
}

#[derive(Subcommand)]
pub enum DatabaseTablesCommands {
/// List tables in a managed database
List {
/// Database name or connection ID
database: String,

/// Filter by schema name
#[arg(long)]
schema: Option<String>,

/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},

/// Load a parquet file into a table (creates or replaces the table)
Load {
/// Database name or connection ID
database: String,

/// Table name
table: String,

/// Schema name (default: public)
#[arg(long, default_value = "public")]
schema: String,

/// Path to a local parquet file to upload and load
#[arg(long, conflicts_with = "upload_id")]
file: Option<String>,

/// Use a previously staged upload ID from `POST /v1/files` instead of uploading
#[arg(long)]
upload_id: Option<String>,
},

/// Delete a table from a managed database
Delete {
/// Database name or connection ID
database: String,

/// Table name
table: String,

/// Schema name (default: public)
#[arg(long, default_value = "public")]
schema: String,
},
}

#[derive(Subcommand)]
pub enum ConnectionsCommands {
/// Interactively create a new connection
Expand Down
Loading
Loading