Skip to content

Commit b0df207

Browse files
committed
feat: add MotherDuck support to CLI
Add --database-path and --mother-duck-token options to the create-duckdb command to allow users to configure MotherDuck connections via the CLI. Changes: - Add --database-path flag to create-duckdb command (removed -d short option to avoid conflict with global --debug flag) - Add --mother-duck-token flag for MotherDuck API token - Add additionalExtensions field to DuckDBConnectionOptions/Config - Document MotherDuck usage in README with examples Signed-off-by: James Swirhun <james@ms2.co>
1 parent 3c11258 commit b0df207

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,39 @@ npx malloy-cli ...
1515
```
1616

1717
Documentation is available on the [Malloy documentation website](https://malloydata.github.io/documentation/malloy_cli/index).
18+
19+
## MotherDuck Support
20+
21+
The CLI supports [MotherDuck](https://motherduck.com/) connections. To connect to MotherDuck, use a database path that starts with `md:` or `motherduck:`.
22+
23+
### Option 1: CLI with token flag
24+
25+
```shell
26+
malloy-cli connections create-duckdb my-motherduck \
27+
--database-path "md:my_database" \
28+
--mother-duck-token "your_motherduck_token"
29+
```
30+
31+
### Option 2: Environment variable
32+
33+
```shell
34+
export MOTHERDUCK_TOKEN="your_token"
35+
malloy-cli connections create-duckdb my-motherduck --database-path "md:my_database"
36+
```
37+
38+
### Option 3: Config file
39+
40+
Create or edit your config file (typically `~/.config/malloy/config.json`):
41+
42+
```json
43+
{
44+
"connections": [{
45+
"name": "motherduck",
46+
"backend": "duckdb",
47+
"databasePath": "md:my_database",
48+
"motherDuckToken": "your_token"
49+
}]
50+
}
51+
```
52+
53+
**Token precedence:** config value > `MOTHERDUCK_TOKEN` env var > `motherduck_token` env var

src/cli.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ export function createCLI(): Command {
231231
.command('create-duckdb')
232232
.description('add a new DuckDB database connection')
233233
.argument('<name>')
234-
.option('-d, --database-path <database>')
234+
.option('--database-path <path>', 'path to DuckDB database file or MotherDuck (e.g., md:database_name)')
235+
.option('--mother-duck-token <token>', 'MotherDuck API token')
235236
.action(createDuckDbConnectionCommand);
236237

237238
connections

src/connections/connection_types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ export interface DuckDBConnectionOptions {
8585
workingDirectory?: string;
8686
databasePath?: string;
8787
motherDuckToken?: string;
88+
additionalExtensions?: string[];
8889
}
8990

9091
export interface DuckDBConnectionConfig extends BaseConnectionConfig {
9192
backend: ConnectionBackend.DuckDB;
9293
workingDirectory?: string;
9394
databasePath?: string;
9495
motherDuckToken?: string;
96+
additionalExtensions?: string[];
9597
}
9698

9799
export interface SnowflakeConnectionOptions {

0 commit comments

Comments
 (0)