← All procedures
sqlite.snapshot
This function writes a copy of an open database to a file with `VACUUM INTO`. The copy is one consistent state, and writers can continue during the copy. The function writes a temporary file first, and then it replaces the file at the path. Thus a reader of the path sees the old copy or the new copy.
CLI- Package
- @procedures/sqlite · README
- Path
["sqlite","snapshot"]- CLI
mark sqlite snapshot --db <object> --path <string>- As data
{"$proc":["sqlite","snapshot"],"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","snapshot"], { db: {}, path: "<path>" });
console.log(JSON.stringify(result));From the command line
$ mark sqlite snapshot --db <object> --path <string>
As data, in a program
{
"$proc": ["sqlite", "snapshot"],
"input": { "db": {}, "path": "<path>" }
}Input
Output
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 of the database. A handle of a node:sqlite#DatabaseSync. The procedure that opens it gives it, and handle.close closes it."
},
"path": {
"type": "string",
"description": "The path of the copy. A file at the path gets the new copy."
}
},
"required": [
"db",
"path"
],
"additionalProperties": false
},
"output": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "This value is the path of the copy."
},
"bytes": {
"type": "number",
"description": "This value is the size of the copy in bytes."
}
},
"required": [
"path",
"bytes"
],
"additionalProperties": {}
}
}