← All procedures

db.execute

Execute a SQL statement (INSERT, UPDATE, DELETE)

MCPCLI
Package
@procedures/sqlite · README
Path
["db","execute"]
CLI
mark db execute --sql <string>
MCP tool
db.execute on the dev-tools server
As data
{"$proc":["db","execute"],"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","execute"], { sql: "<sql>" });
console.log(JSON.stringify(result));

From the command line

$ mark db execute --sql <string>

As data, in a program

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

Input

FieldTypeRequiredDefaultDescription
sqlstringyesThe SQL statement or script (INSERT, UPDATE, DELETE, CREATE TABLE, ...)
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
changesnumberyesThe number of rows that the statements changed
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "sql": {
        "type": "string",
        "description": "The SQL statement or script (INSERT, UPDATE, DELETE, CREATE TABLE, ...)"
      },
      "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": {
      "changes": {
        "type": "number",
        "description": "The number of rows that the statements changed"
      }
    },
    "required": [
      "changes"
    ],
    "additionalProperties": {}
  }
}