Skip to main content
datagen-data is the command-line tool that runs inside DataGen sandboxes to find datasets, read their documentation and query them with SQL. DataGen installs it on two kinds of turns: A deployment administrator can turn the CLI off for the whole deployment. The CLI is not something you install or call from your own machine. To give an agent data, connect a model to it (see Use data in agents and apps); the agent finds the CLI through its datagen-data skill.

Location and setup

The script is not on PATH; call it by its full path:
If DuckDB is missing, the CLI says so and suggests pip install --user --break-system-packages duckdb. Add duckdb to the agent’s Sandbox Environment to avoid installing it on every run. The credential is a signed grant for the current turn. Access is checked again on every call: removing a model from an agent takes effect on the agent’s next command.

Commands

On an agent turn, any other command prints the usage and exits.

list

Lists every dataset the turn can reach as a table with kind, sql_name, name, detail and description. For a model, detail shows the published version and execution mode; for a source, its connection and column count. Start here.
Finds datasets whose name or description contains every term (listed first), then columns whose name, type or description contains a term. Case-insensitive.

describe

Prints one dataset’s page: columns and types, column descriptions, freshness, related datasets and the model’s guide (model.md). On a Data Builder turn, a model’s page also includes its published SQL. Read it before writing SQL against a model.

sql

Runs one query with DuckDB in the sandbox and prints the rows. Refer to datasets by their SQL names, exactly as list prints them. A trailing semicolon is ignored.
How the query runs:
  • Materialized models are read straight from their Parquet snapshot over signed URLs; DuckDB fetches only the columns and row groups it needs.
  • On a Data Builder turn, PostgreSQL sources are read live through DataGen’s SQL proxy (on deployments that run one), and live models are evaluated from their SQL.
  • On a Data Builder turn, a query that reads any other source (MySQL, Oracle, Parquet on S3, workspace files) or calls oracle_query(...) runs on the DataGen analytics service instead. It returns at most 500 rows and --out is not available; aggregate or filter in the query.
  • On the Data Builder turn of a Native SQL model, every query runs on that model’s database connection in its own SQL dialect, with the same 500-row limit.

values

Lists the distinct values of one column with their counts, most frequent first. Use it to find the exact literal before filtering on it.

check

Data Builder only.
Validates model SQL against the rules applied at publish and refresh (dataset names, allowed functions) without reading any data. Prints OK: passes the publish and refresh rules; reads ... with the datasets the SQL reads, or the reason it fails.

connect

Data Builder only.
For querying live PostgreSQL sources from your own DuckDB or psql session. Writes ~/.pg_service.conf and ~/.pgpass for this turn and prints, per connection, an ATTACH 'service=datagen_<alias>' AS <alias> (TYPE postgres, READ_ONLY) line and the mapping from each source’s SQL name to <alias>.<schema>.<table>. The entries rotate every turn; run connect again in a new turn. For Oracle connections it prints how to call oracle_query(...), and for a Native SQL model, which connection and dialect its queries run on.

snapshot

Data Builder only.
Prints a SELECT * FROM read_parquet('<signed URL>') statement for a published materialized model, for use in your own DuckDB session. The URL expires after 5 minutes; run the command again for a new one. Nothing is downloaded.

sync

Data Builder only.
Re-downloads the catalog as read-only text files to DIR (default /tmp/datagen-data-catalog), the same content list and describe render.

SQL names

Queries use DuckDB SQL, except on a Native SQL model’s builder turn. An agent turn only ever sees analytic models.

Output

Command output is plain text, capped at 60,000 characters per call. sql and values print tab-separated rows inside a random <untrusted-data-...> boundary, followed by a summary:
Row values are data from your systems and may contain text that reads like an instruction; the boundary marks them so the agent treats them as data only. Each cell is cut to 500 characters and newlines in cells are replaced with spaces. When more rows exist than were printed, the summary says so; aggregate, filter, or use --out.

Errors

Errors go to standard error, prefixed with datagen-data:. The exit code is 2 for a usage error and 1 for a failed request or query. Query errors from DuckDB or the database are passed through with the dataset names put back in place of internal ones, so you can fix the SQL from the message.

Next

Use data in agents and apps

Connect a published model to an agent.

Build analytic models

Build the models the CLI reads.