-
Notifications
You must be signed in to change notification settings - Fork 180
feat(wren): extend standalone CLI with MySQL support and auto-discovery #1476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a00978b
feat(wren): extend standalone CLI with MySQL datasource tests
douenergy 14cf2c4
feat(wren): auto-discover mdl.json/conn.json and support bare wren --sql
douenergy 786024b
docs(wren): update README and add wren-query Claude Code skill
douenergy 0989b75
style(wren): apply ruff formatting after review fixes
douenergy 03cdfb5
fix(wren): read mdl.json and conn.json from ~/.wren instead of cwd
douenergy e0b4d53
docs(wren): update README and cli.md to reference ~/.wren config home
douenergy c5efa3c
fix(wren): disclaimer for untested connectors, consolidate CI into ma…
douenergy aeddb7d
docs(wren): remove untested BigQuery, Redshift, and Doris from README
douenergy e07e6a1
fix(wren): align connection file name with mcp-server and rename tran…
douenergy 89d1534
fix(wren): remove duplicate wren-core-py entry in uv.lock
douenergy 4aee44b
fix(wren): address CodeRabbit review comments on cli.py
douenergy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Wren Engine Skills | ||
|
|
||
| Claude Code skills for the Wren Engine CLI. | ||
|
|
||
| ## Available skills | ||
|
|
||
| | Skill | Trigger | Description | | ||
| |-------|---------|-------------| | ||
| | [`wren-query`](wren-query/SKILL.md) | `/wren-query [sql]` | Run, dry-run, or validate a SQL query through the Wren semantic CLI | | ||
|
|
||
| ## Usage | ||
|
|
||
| Skills are invoked via slash commands in Claude Code: | ||
|
|
||
| ``` | ||
| /wren-query SELECT order_id FROM "orders" LIMIT 5 | ||
| /wren-query --dry-plan SELECT * FROM "orders" | ||
| /wren-query --validate SELECT * FROM "NonExistent" | ||
| ``` | ||
|
|
||
| See each skill's `SKILL.md` for full details. | ||
douenergy marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| --- | ||
| name: wren-query | ||
| description: > | ||
| Run, dry-plan, or validate a SQL query through the Wren semantic CLI. | ||
| Use when the user asks to query a data source using wren, run wren --sql, | ||
| dry-plan SQL through MDL, or test a wren query against MySQL/Postgres/etc. | ||
| argument-hint: "[sql query]" | ||
| allowed-tools: Read, Bash(uv run wren *), Bash(wren *) | ||
| --- | ||
|
|
||
| The user wants to run a Wren CLI command. $ARGUMENTS is the SQL query or instruction. | ||
|
|
||
| ## What to do | ||
|
|
||
| 1. **Check for `~/.wren/mdl.json` and `~/.wren/connection_info.json`** using Read or Glob. | ||
| - If either is missing, tell the user what's needed and show the format below. | ||
| - If both exist, proceed directly. | ||
|
|
||
| 2. **Run the appropriate command** based on what the user asked: | ||
|
|
||
| | Intent | Command | | ||
| |--------|---------| | ||
| | Execute and return results | `uv run wren --sql '...'` | | ||
| | Translate to native SQL (no DB) | `uv run wren dry-plan --sql '...'` | | ||
| | Validate without fetching rows | `uv run wren dry-run --sql '...'` | | ||
| | Check SQL is valid | `uv run wren validate --sql '...'` | | ||
|
|
||
| If `wren` is installed globally (not via uv), use `wren` directly instead of `uv run wren`. | ||
|
|
||
| 3. **Show the result** and explain what happened. | ||
|
|
||
| --- | ||
|
|
||
| ## Required files | ||
|
|
||
| Both files are auto-discovered from `~/.wren/`. | ||
|
|
||
| ### mdl.json — semantic model | ||
| ```json | ||
| { | ||
| "catalog": "wren", | ||
| "schema": "public", | ||
| "models": [ | ||
| { | ||
| "name": "orders", | ||
| "tableReference": { "schema": "mydb", "table": "orders" }, | ||
| "columns": [ | ||
| { "name": "order_id", "type": "integer" }, | ||
| { "name": "total", "type": "double" }, | ||
| { "name": "status", "type": "varchar" } | ||
| ], | ||
| "primaryKey": "order_id" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ### connection_info.json — connection info (include `datasource` field) | ||
| ```json | ||
| { | ||
| "datasource": "mysql", | ||
| "host": "localhost", | ||
| "port": 3306, | ||
| "database": "mydb", | ||
| "user": "root", | ||
| "password": "secret" | ||
| } | ||
| ``` | ||
|
|
||
| Supported datasource values: `mysql`, `postgres`, `bigquery`, `snowflake`, | ||
| `clickhouse`, `trino`, `mssql`, `databricks`, `redshift`, `oracle`, `duckdb`. | ||
|
|
||
| --- | ||
|
|
||
| ## Override flags | ||
|
|
||
| When needed, flags can override the defaults: | ||
|
|
||
| ```bash | ||
| wren --sql '...' --mdl other-mdl.json --connection-file prod-connection_info.json | ||
| wren --sql '...' --output csv # table (default) | csv | json | ||
| wren --sql '...' --limit 100 | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Common errors | ||
|
|
||
| | Error | Fix | | ||
| |-------|-----| | ||
| | `mdl.json not found` | Create `~/.wren/mdl.json` | | ||
| | `connection_info.json not found` | Create `~/.wren/connection_info.json` with a `datasource` field | | ||
| | `datasource key not found` | Add `"datasource": "mysql"` to connection_info.json | | ||
| | `unknown datasource 'X'` | Check spelling; see supported values above | | ||
| | Connection refused | Confirm the DB is running and host/port are correct | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
douenergy marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,91 @@ | ||
| # wren | ||
| # wren-engine | ||
|
|
||
| Wren Engine CLI and Python SDK — semantic SQL layer for 20+ data sources. | ||
|
|
||
| Translate natural SQL queries through an MDL (Modeling Definition Language) semantic layer and execute them against your database. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install wren-engine | ||
| pip install wren-engine[mysql] # MySQL | ||
| pip install wren-engine[postgres] # PostgreSQL | ||
| pip install wren-engine[duckdb] # DuckDB (local files) | ||
| pip install wren-engine[all] # All connectors | ||
| ``` | ||
|
|
||
| ## Quick start | ||
|
|
||
| **1. Create `~/.wren/mdl.json`** — your semantic model: | ||
|
|
||
| ```json | ||
| { | ||
| "catalog": "wren", | ||
| "schema": "public", | ||
| "models": [ | ||
| { | ||
| "name": "orders", | ||
| "tableReference": { "schema": "mydb", "table": "orders" }, | ||
| "columns": [ | ||
| { "name": "order_id", "type": "integer" }, | ||
| { "name": "customer_id", "type": "integer" }, | ||
| { "name": "total", "type": "double" }, | ||
| { "name": "status", "type": "varchar" } | ||
| ], | ||
| "primaryKey": "order_id" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| **2. Create `~/.wren/connection_info.json`** — your connection: | ||
|
|
||
| ```json | ||
| { | ||
| "datasource": "mysql", | ||
| "host": "localhost", | ||
| "port": 3306, | ||
| "database": "mydb", | ||
| "user": "root", | ||
| "password": "secret" | ||
| } | ||
| ``` | ||
|
|
||
| **3. Run queries** — `wren` auto-discovers both files from `~/.wren`: | ||
|
|
||
| ```bash | ||
| wren --sql 'SELECT order_id FROM "orders" LIMIT 10' | ||
| ``` | ||
|
|
||
| ## Usage | ||
| For the full CLI reference and per-datasource `connection_info.json` formats, see [`docs/cli.md`](docs/cli.md) and [`docs/connections.md`](docs/connections.md). | ||
|
|
||
| --- | ||
|
|
||
| ## Python SDK | ||
|
|
||
| ```python | ||
| import base64, orjson | ||
| from wren import WrenEngine, DataSource | ||
|
|
||
| manifest = { ... } # your MDL dict | ||
| manifest_str = base64.b64encode(orjson.dumps(manifest)).decode() | ||
|
|
||
| with WrenEngine(manifest_str, DataSource.mysql, {"host": "...", ...}) as engine: | ||
| result = engine.query('SELECT * FROM "orders" LIMIT 10') | ||
| print(result.to_pandas()) | ||
| ``` | ||
|
|
||
| See the [Wren Engine documentation](https://getwren.ai) for details. | ||
| --- | ||
|
|
||
| ## Running tests | ||
|
|
||
| Install dev dependencies first: | ||
|
|
||
| ```bash | ||
| just install-dev | ||
| ``` | ||
|
|
||
| | Command | What it runs | Docker needed | | ||
| |---------|-------------|---------------| | ||
| | `just test-unit` | Unit tests (transpile, dry-plan, context manager) | No | | ||
| | `just test-duckdb` | DuckDB connector tests — generates TPCH data via `dbgen` | No | | ||
| | `just test-postgres` | PostgreSQL connector tests — spins up a container | Yes | | ||
| | `just test-unit` | Unit tests | No | | ||
| | `just test-duckdb` | DuckDB connector tests | No | | ||
| | `just test-postgres` | PostgreSQL connector tests | Yes | | ||
| | `just test-mysql` | MySQL connector tests | Yes | | ||
| | `just test` | All tests | Yes | | ||
|
|
||
| Run a specific connector via marker: | ||
|
|
||
| ```bash | ||
| just test-connector postgres | ||
| ``` | ||
|
|
||
| To add tests for a new connector, subclass `WrenQueryTestSuite` in | ||
| `tests/connectors/test_<name>.py` and provide a class-scoped `engine` fixture. | ||
| All base tests are inherited automatically. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # CLI reference | ||
|
|
||
| ## Default command — query | ||
|
|
||
| Running `wren --sql '...'` executes a query and prints the result. This is the same as `wren query --sql '...'`. | ||
|
|
||
| ```bash | ||
| wren --sql 'SELECT COUNT(*) FROM "orders"' | ||
| wren --sql 'SELECT * FROM "orders" LIMIT 5' --output csv | ||
| wren --sql 'SELECT * FROM "orders"' --limit 100 --output json | ||
| ``` | ||
|
|
||
| Output formats: `table` (default), `csv`, `json`. | ||
|
|
||
| ## `wren query` | ||
|
|
||
| Execute SQL and return results. | ||
|
|
||
| ```bash | ||
| wren query --sql 'SELECT order_id, total FROM "orders" ORDER BY total DESC LIMIT 5' | ||
| ``` | ||
|
|
||
| ## `wren dry-plan` | ||
|
|
||
| Translate MDL SQL to the native dialect SQL for your data source. No database connection required. | ||
|
|
||
| ```bash | ||
| wren dry-plan --sql 'SELECT order_id FROM "orders"' | ||
| ``` | ||
|
|
||
| ## `wren dry-run` | ||
|
|
||
| Validate SQL against the live database without returning rows. Prints `OK` on success. | ||
|
|
||
| ```bash | ||
| wren dry-run --sql 'SELECT * FROM "orders" LIMIT 1' | ||
| ``` | ||
|
|
||
| ## `wren validate` | ||
|
|
||
| Same as `dry-run` but prints `Valid` / `Invalid: <reason>`. | ||
|
|
||
| ```bash | ||
| wren validate --sql 'SELECT * FROM "NonExistent"' | ||
| # Invalid: table not found ... | ||
| ``` | ||
|
|
||
| ## Overriding defaults | ||
|
|
||
| All flags are optional when `~/.wren/mdl.json` and `~/.wren/connection_info.json` exist: | ||
|
|
||
| ```bash | ||
| wren --sql '...' \ | ||
| --mdl /path/to/other-mdl.json \ | ||
| --connection-file /path/to/prod-connection_info.json \ | ||
| --datasource postgres | ||
| ``` | ||
|
|
||
| Or pass connection info inline: | ||
|
|
||
| ```bash | ||
| wren --sql 'SELECT COUNT(*) FROM "orders"' \ | ||
| --connection-info '{"datasource":"mysql","host":"localhost","port":3306,"database":"mydb","user":"root","password":"secret"}' | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a language identifier to the usage code fence (MD040).
Line 15 opens a fenced block without a language, which triggers the configured markdownlint rule.
📝 Proposed fix
Verify each finding against the current code and only fix it if needed.
In @.claude/skills/README.md around lines 15 - 19, The fenced code block in
README.md lacks a language tag (MD040); update the triple-backtick that opens
the block for the usage examples to include a language identifier (e.g., add