Save Query

Save a SQL query to a Draxlr database.

Tool: draxlr_save_query

Saves a SQL query to a database so it appears under the database's saved queries. You can either pass the sql directly (it will be executed and then saved) or pass a queryId returned by Run Query.

Parameters

ParameterTypeRequiredDescription
databaseIdstringYesThe database id the query belongs to
namestringYesName for the saved query
sqlstringNoThe SQL to save. Provide either this or queryId
queryIdstringNoA queryId from Run Query. Provide either this or sql
descriptionstringNoOptional description for the saved query
allowDuplicateNamebooleanNoAllow saving even if a query with the same name already exists

Provide sql or queryId:

You must supply at least one of sql or queryId. If both are omitted, the command returns an error.

Example

"Save this query as Orders by status on my Sales DB."

Arguments:

{
  "databaseId": "665f1c2a9b1e4a0012ab34cd",
  "name": "Orders by status",
  "sql": "SELECT status, COUNT(*) AS orders FROM orders GROUP BY status",
  "description": "Order counts grouped by status"
}

Response

{
  "message": "Saved query \"Orders by status\".",
  "query": {
    "_id": "6690aa11bc2e4a0012cd77ee",
    "name": "Orders by status",
    "description": "Order counts grouped by status"
  },
  "url": "https://app.draxlr.com/explore/665f1c2a9b1e4a0012ab34cd/6690aa11bc2e4a0012cd77ee"
}
FieldDescription
messageConfirmation message
queryThe saved query, including its _id
urlA link to view the saved query in Draxlr