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:
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
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.
search
describe
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
list prints them. A trailing semicolon is ignored.
- 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--outis 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
check
Data Builder only.OK: passes the publish and refresh rules; reads ... with the datasets the SQL reads, or the reason it fails.
connect
Data Builder only.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.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.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:
--out.
Errors
Errors go to standard error, prefixed withdatagen-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.