Create DataLens saved SQL query
datalens_sqlqueries_createSave a named SQL query to a DataLens workbook and return it, with a chosen connection, optional parameters, and description.
Instructions
Save a SQL query in a workbook and return it.
Experimental in the DataLens API and written from its document: not measured. An
organization whose SQL editor is off answers 403 SQL_EDITOR_NOT_ALLOWED.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"workbook_id": "<workbook_id>",
"name": "<name>",
"connection_id": "<connection_id>",
"query": "<query>"
},
"name": "datalens_sqlqueries_create"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The query's name in the workbook. | |
| query | Yes | The text of the query. | |
| params | No | The parameters the text takes: a name, a type and a default each. | |
| dry_run | No | Send nothing: answer `{dry_run: true, request}`, the first write the tool would make (null: none). | |
| description | No | A description. | |
| workbook_id | Yes | The workbook to keep it in. | |
| connection_id | Yes | The connection it runs over: PostgreSQL, ClickHouse, MySQL, Greenplum, Trino. |