← All procedures

db.query

Execute a SQL SELECT query

MCPCLI
Package
@procedures/sqlite · README
Path
["db","query"]
CLI
mark db query --sql <string>
MCP tool
db.query on the dev-tools server
As data
{"$proc":["db","query"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/sqlite"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["db","query"], { sql: "<sql>" });
console.log(JSON.stringify(result));

From the command line

$ mark db query --sql <string>

As data, in a program

{ "$proc": ["db", "query"], "input": { "sql": "<sql>" } }

Input

FieldTypeRequiredDefaultDescription
sqlstringyesThe SQL query (SELECT)
paramsany[]noThe values of the ? placeholders of the SQL, in order
dbPathstringnoThe SQLite database file (default: /home/runner/logs/cli/cli.db). A query does not make a missing file.

Output

FieldTypeRequiredDefaultDescription
columnsstring[]yesThe column names
rowsobject[]yesThe rows, one object for each row
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "sql": {
        "type": "string",
        "description": "The SQL query (SELECT)"
      },
      "params": {
        "description": "The values of the ? placeholders of the SQL, in order",
        "type": "array",
        "items": {}
      },
      "dbPath": {
        "description": "The SQLite database file (default: /home/runner/logs/cli/cli.db). A query does not make a missing file.",
        "type": "string"
      }
    },
    "required": [
      "sql"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "columns": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "The column names"
      },
      "rows": {
        "type": "array",
        "items": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        },
        "description": "The rows, one object for each row"
      }
    },
    "required": [
      "columns",
      "rows"
    ],
    "additionalProperties": {}
  }
}