← All procedures

sqlite.checkpoint

This function does a checkpoint of the write-ahead log, and gives its result.

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

Use it

In TypeScript

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

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

From the command line

$ mark sqlite checkpoint --db <object>

As data, in a program

{ "$proc": ["sqlite", "checkpoint"], "input": { "db": {} } }

Input

FieldTypeRequiredDefaultDescription
dbobjectyesThe connection. A handle of a node:sqlite#DatabaseSync. The procedure that opens it gives it, and handle.close closes it.
mode"FULL" | "PASSIVE" | "RESTART" | "TRUNCATE"noThe mode of `PRAGMA wal_checkpoint`. The default is `PASSIVE`: it does not wait for other connections.

Output

FieldTypeRequiredDefaultDescription
busybooleanyesThis value is true when a different connection stopped the checkpoint before its end.
lognumberyesThis value is the number of pages in the log.
checkpointednumberyesThis value is the number of pages of the log that the checkpoint copied into the database file.
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "db": {
        "type": "object",
        "properties": {
          "handle": {
            "type": "string",
            "minLength": 1,
            "description": "The id of the handle. The procedure that opens the object gives it."
          }
        },
        "required": [
          "handle"
        ],
        "additionalProperties": false,
        "x-procedures-handle": "node:sqlite#DatabaseSync",
        "description": "The connection. A handle of a node:sqlite#DatabaseSync. The procedure that opens it gives it, and handle.close closes it."
      },
      "mode": {
        "type": "string",
        "enum": [
          "FULL",
          "PASSIVE",
          "RESTART",
          "TRUNCATE"
        ],
        "description": "The mode of `PRAGMA wal_checkpoint`. The default is `PASSIVE`: it does not wait for other connections."
      }
    },
    "required": [
      "db"
    ],
    "additionalProperties": false
  },
  "output": {
    "type": "object",
    "properties": {
      "busy": {
        "type": "boolean",
        "description": "This value is true when a different connection stopped the checkpoint before its end."
      },
      "log": {
        "type": "number",
        "description": "This value is the number of pages in the log."
      },
      "checkpointed": {
        "type": "number",
        "description": "This value is the number of pages of the log that the checkpoint copied into the database file."
      }
    },
    "required": [
      "busy",
      "log",
      "checkpointed"
    ],
    "additionalProperties": {}
  }
}