{
  "type": "module",
  "source": "doc/api/sqlite.md",
  "modules": [
    {
      "textRaw": "SQLite",
      "name": "sqlite",
      "introduced_in": "v22.5.0",
      "meta": {
        "added": [
          "v22.5.0"
        ],
        "changes": []
      },
      "stability": 1,
      "stabilityText": ".1 - Active development.",
      "desc": "<p><strong>Source Code:</strong> <a href=\"https://github.com/nodejs/node/blob/v24.1.0/lib/sqlite.js\">lib/sqlite.js</a></p>\n<p>The <code>node:sqlite</code> module facilitates working with SQLite databases.\nTo access it:</p>\n<pre><code class=\"language-mjs\">import sqlite from 'node:sqlite';\n</code></pre>\n<pre><code class=\"language-cjs\">const sqlite = require('node:sqlite');\n</code></pre>\n<p>This module is only available under the <code>node:</code> scheme.</p>\n<p>The following example shows the basic usage of the <code>node:sqlite</code> module to open\nan in-memory database, write data to the database, and then read the data back.</p>\n<pre><code class=\"language-mjs\">import { DatabaseSync } from 'node:sqlite';\nconst database = new DatabaseSync(':memory:');\n\n// Execute SQL statements from strings.\ndatabase.exec(`\n  CREATE TABLE data(\n    key INTEGER PRIMARY KEY,\n    value TEXT\n  ) STRICT\n`);\n// Create a prepared statement to insert data into the database.\nconst insert = database.prepare('INSERT INTO data (key, value) VALUES (?, ?)');\n// Execute the prepared statement with bound values.\ninsert.run(1, 'hello');\ninsert.run(2, 'world');\n// Create a prepared statement to read data from the database.\nconst query = database.prepare('SELECT * FROM data ORDER BY key');\n// Execute the prepared statement and log the result set.\nconsole.log(query.all());\n// Prints: [ { key: 1, value: 'hello' }, { key: 2, value: 'world' } ]\n</code></pre>\n<pre><code class=\"language-cjs\">'use strict';\nconst { DatabaseSync } = require('node:sqlite');\nconst database = new DatabaseSync(':memory:');\n\n// Execute SQL statements from strings.\ndatabase.exec(`\n  CREATE TABLE data(\n    key INTEGER PRIMARY KEY,\n    value TEXT\n  ) STRICT\n`);\n// Create a prepared statement to insert data into the database.\nconst insert = database.prepare('INSERT INTO data (key, value) VALUES (?, ?)');\n// Execute the prepared statement with bound values.\ninsert.run(1, 'hello');\ninsert.run(2, 'world');\n// Create a prepared statement to read data from the database.\nconst query = database.prepare('SELECT * FROM data ORDER BY key');\n// Execute the prepared statement and log the result set.\nconsole.log(query.all());\n// Prints: [ { key: 1, value: 'hello' }, { key: 2, value: 'world' } ]\n</code></pre>",
      "classes": [
        {
          "textRaw": "Class: `DatabaseSync`",
          "type": "class",
          "name": "DatabaseSync",
          "meta": {
            "added": [
              "v22.5.0"
            ],
            "changes": [
              {
                "version": "v24.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/57752",
                "description": "Add `timeout` option."
              },
              {
                "version": [
                  "v23.10.0",
                  "v22.15.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/56991",
                "description": "The `path` argument now supports Buffer and URL objects."
              }
            ]
          },
          "desc": "<p>This class represents a single <a href=\"https://www.sqlite.org/c3ref/sqlite3.html\">connection</a> to a SQLite database. All APIs\nexposed by this class execute synchronously.</p>",
          "methods": [
            {
              "textRaw": "`database.aggregate(name, options)`",
              "type": "method",
              "name": "aggregate",
              "meta": {
                "added": [
                  "v24.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Registers a new aggregate function with the SQLite database. This method is a wrapper around\n<a href=\"https://www.sqlite.org/c3ref/create_function.html\"><code>sqlite3_create_window_function()</code></a>.</p>\n<ul>\n<li><code>name</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\">&lt;string&gt;</a> The name of the SQLite function to create.</li>\n<li><code>options</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\">&lt;Object&gt;</a> Function configuration settings.\n<ul>\n<li><code>deterministic</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\" class=\"type\">&lt;boolean&gt;</a> If <code>true</code>, the <a href=\"https://www.sqlite.org/c3ref/c_deterministic.html\"><code>SQLITE_DETERMINISTIC</code></a> flag is\nset on the created function. <strong>Default:</strong> <code>false</code>.</li>\n<li><code>directOnly</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\" class=\"type\">&lt;boolean&gt;</a> If <code>true</code>, the <a href=\"https://www.sqlite.org/c3ref/c_deterministic.html\"><code>SQLITE_DIRECTONLY</code></a> flag is set on\nthe created function. <strong>Default:</strong> <code>false</code>.</li>\n<li><code>useBigIntArguments</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\" class=\"type\">&lt;boolean&gt;</a> If <code>true</code>, integer arguments to <code>options.step</code> and <code>options.inverse</code>\nare converted to <code>BigInt</code>s. If <code>false</code>, integer arguments are passed as\nJavaScript numbers. <strong>Default:</strong> <code>false</code>.</li>\n<li><code>varargs</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type\" class=\"type\">&lt;boolean&gt;</a> If <code>true</code>, <code>options.step</code> and <code>options.inverse</code> may be invoked with any number of\narguments (between zero and <a href=\"https://www.sqlite.org/limits.html#max_function_arg\"><code>SQLITE_MAX_FUNCTION_ARG</code></a>). If <code>false</code>,\n<code>inverse</code> and <code>step</code> must be invoked with exactly <code>length</code> arguments.\n<strong>Default:</strong> <code>false</code>.</li>\n<li><code>start</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\">&lt;string&gt;</a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Null_type\" class=\"type\">&lt;null&gt;</a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array\" class=\"type\">&lt;Array&gt;</a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\" class=\"type\">&lt;Object&gt;</a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\">&lt;Function&gt;</a> The identity\nvalue for the aggregation function. This value is used when the aggregation\nfunction is initialized. When a <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\">&lt;Function&gt;</a> is passed the identity will be its return value.</li>\n<li><code>step</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\">&lt;Function&gt;</a> The function to call for each row in the aggregation. The\nfunction receives the current state and the row value. The return value of\nthis function should be the new state.</li>\n<li><code>result</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\">&lt;Function&gt;</a> The function to call to get the result of the\naggregation. The function receives the final state and should return the\nresult of the aggregation.</li>\n<li><code>inverse</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\" class=\"type\">&lt;Function&gt;</a> When this function is provided, the <code>aggregate</code> method will work as a window function.\nThe function receives the current state and the dropped row value. The return value of this function should be the\nnew state.</li>\n</ul>\n</li>\n</ul>\n<p>When used as a window function, the <code>result</code> function will be called multiple times.</p>\n<pre><code class=\"language-cjs\">const { DatabaseSync } = require('node:sqlite');\n\nconst db = new DatabaseSync(':memory:');\ndb.exec(`\n  CREATE TABLE t3(x, y);\n  INSERT INTO t3 VALUES ('a', 4),\n                        ('b', 5),\n                        ('c', 3),\n                        ('d', 8),\n                        ('e', 1);\n`);\n\ndb.aggregate('sumint', {\n  start: 0,\n  step: (acc, value) => acc + value,\n});\n\ndb.prepare('SELECT sumint(y) as total FROM t3').get(); // { total: 21 }\n</code></pre>\n<pre><code class=\"language-mjs\">import { DatabaseSync } from 'node:sqlite';\n\nconst db = new DatabaseSync(':memory:');\ndb.exec(`\n  CREATE TABLE t3(x, y);\n  INSERT INTO t3 VALUES ('a', 4),\n                        ('b', 5),\n                        ('c', 3),\n                        ('d', 8),\n                        ('e', 1);\n`);\n\ndb.aggregate('sumint', {\n  start: 0,\n  step: (acc, value) => acc + value,\n});\n\ndb.prepare('SELECT sumint(y) as total FROM t3').get(); // { total: 21 }\n</code></pre>"
            },
            {
              "textRaw": "`database.close()`",
              "type": "method",
              "name": "close",
              "meta": {
                "added": [
                  "v22.5.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Closes the database connection. An exception is thrown if the database is not\nopen. This method is a wrapper around <a href=\"https://www.sqlite.org/c3ref/close.html\"><code>sqlite3_close_v2()</code></a>.</p>"
            },
            {
              "textRaw": "`database.loadExtension(path)`",
              "type": "method",
              "name": "loadExtension",
              "meta": {
                "added": [
                  "v23.5.0",
                  "v22.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`path` {string} The path to the shared library to load.",
                      "name": "path",
                      "type": "string",
                      "desc": "The path to the shared library to load."
                    }
                  ]
                }
              ],
              "desc": "<p>Loads a shared library into the database connection. This method is a wrapper\naround <a href=\"https://www.sqlite.org/c3ref/load_extension.html\"><code>sqlite3_load_extension()</code></a>. It is required to enable the\n<code>allowExtension</code> option when constructing the <code>DatabaseSync</code> instance.</p>"
            },
            {
              "textRaw": "`database.enableLoadExtension(allow)`",
              "type": "method",
              "name": "enableLoadExtension",
              "meta": {
                "added": [
                  "v23.5.0",
                  "v22.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`allow` {boolean} Whether to allow loading extensions.",
                      "name": "allow",
                      "type": "boolean",
                      "desc": "Whether to allow loading extensions."
                    }
                  ]
                }
              ],
              "desc": "<p>Enables or disables the <code>loadExtension</code> SQL function, and the <code>loadExtension()</code>\nmethod. When <code>allowExtension</code> is <code>false</code> when constructing, you cannot enable\nloading extensions for security reasons.</p>"
            },
            {
              "textRaw": "`database.location([dbName])`",
              "type": "method",
              "name": "location",
              "meta": {
                "added": [
                  "v24.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {string | null} The location of the database file. When using an in-memory database, this method returns null.",
                    "name": "return",
                    "type": "string | null",
                    "desc": "The location of the database file. When using an in-memory database, this method returns null."
                  },
                  "params": [
                    {
                      "textRaw": "`dbName` {string} Name of the database. This can be `'main'` (the default primary database) or any other database that has been added with [`ATTACH DATABASE`][] **Default:** `'main'`.",
                      "name": "dbName",
                      "type": "string",
                      "default": "`'main'`",
                      "desc": "Name of the database. This can be `'main'` (the default primary database) or any other database that has been added with [`ATTACH DATABASE`][]"
                    }
                  ]
                }
              ],
              "desc": "<p>This method is a wrapper around <a href=\"https://sqlite.org/c3ref/db_filename.html\"><code>sqlite3_db_filename()</code></a></p>"
            },
            {
              "textRaw": "`database.exec(sql)`",
              "type": "method",
              "name": "exec",
              "meta": {
                "added": [
                  "v22.5.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`sql` {string} A SQL string to execute.",
                      "name": "sql",
                      "type": "string",
                      "desc": "A SQL string to execute."
                    }
                  ]
                }
              ],
              "desc": "<p>This method allows one or more SQL statements to be executed without returning\nany results. This method is useful when executing SQL statements read from a\nfile. This method is a wrapper around <a href=\"https://www.sqlite.org/c3ref/exec.html\"><code>sqlite3_exec()</code></a>.</p>"
            },
            {
              "textRaw": "`database.function(name[, options], function)`",
              "type": "method",
              "name": "function",
              "meta": {
                "added": [
                  "v23.5.0",
                  "v22.13.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`name` {string} The name of the SQLite function to create.",
                      "name": "name",
                      "type": "string",
                      "desc": "The name of the SQLite function to create."
                    },
                    {
                      "textRaw": "`options` {Object} Optional configuration settings for the function. The following properties are supported:",
                      "name": "options",
                      "type": "Object",
                      "desc": "Optional configuration settings for the function. The following properties are supported:",
                      "options": [
                        {
                          "textRaw": "`deterministic` {boolean} If `true`, the [`SQLITE_DETERMINISTIC`][] flag is set on the created function. **Default:** `false`.",
                          "name": "deterministic",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "If `true`, the [`SQLITE_DETERMINISTIC`][] flag is set on the created function."
                        },
                        {
                          "textRaw": "`directOnly` {boolean} If `true`, the [`SQLITE_DIRECTONLY`][] flag is set on the created function. **Default:** `false`.",
                          "name": "directOnly",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "If `true`, the [`SQLITE_DIRECTONLY`][] flag is set on the created function."
                        },
                        {
                          "textRaw": "`useBigIntArguments` {boolean} If `true`, integer arguments to `function` are converted to `BigInt`s. If `false`, integer arguments are passed as JavaScript numbers. **Default:** `false`.",
                          "name": "useBigIntArguments",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "If `true`, integer arguments to `function` are converted to `BigInt`s. If `false`, integer arguments are passed as JavaScript numbers."
                        },
                        {
                          "textRaw": "`varargs` {boolean} If `true`, `function` may be invoked with any number of arguments (between zero and [`SQLITE_MAX_FUNCTION_ARG`][]). If `false`, `function` must be invoked with exactly `function.length` arguments. **Default:** `false`.",
                          "name": "varargs",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "If `true`, `function` may be invoked with any number of arguments (between zero and [`SQLITE_MAX_FUNCTION_ARG`][]). If `false`, `function` must be invoked with exactly `function.length` arguments."
                        }
                      ]
                    },
                    {
                      "textRaw": "`function` {Function} The JavaScript function to call when the SQLite function is invoked. The return value of this function should be a valid SQLite data type: see [Type conversion between JavaScript and SQLite][]. The result defaults to `NULL` if the return value is `undefined`.",
                      "name": "function",
                      "type": "Function",
                      "desc": "The JavaScript function to call when the SQLite function is invoked. The return value of this function should be a valid SQLite data type: see [Type conversion between JavaScript and SQLite][]. The result defaults to `NULL` if the return value is `undefined`."
                    }
                  ]
                }
              ],
              "desc": "<p>This method is used to create SQLite user-defined functions. This method is a\nwrapper around <a href=\"https://www.sqlite.org/c3ref/create_function.html\"><code>sqlite3_create_function_v2()</code></a>.</p>"
            },
            {
              "textRaw": "`database.open()`",
              "type": "method",
              "name": "open",
              "meta": {
                "added": [
                  "v22.5.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Opens the database specified in the <code>path</code> argument of the <code>DatabaseSync</code>\nconstructor. This method should only be used when the database is not opened via\nthe constructor. An exception is thrown if the database is already open.</p>"
            },
            {
              "textRaw": "`database.prepare(sql)`",
              "type": "method",
              "name": "prepare",
              "meta": {
                "added": [
                  "v22.5.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {StatementSync} The prepared statement.",
                    "name": "return",
                    "type": "StatementSync",
                    "desc": "The prepared statement."
                  },
                  "params": [
                    {
                      "textRaw": "`sql` {string} A SQL string to compile to a prepared statement.",
                      "name": "sql",
                      "type": "string",
                      "desc": "A SQL string to compile to a prepared statement."
                    }
                  ]
                }
              ],
              "desc": "<p>Compiles a SQL statement into a <a href=\"https://www.sqlite.org/c3ref/stmt.html\">prepared statement</a>. This method is a wrapper\naround <a href=\"https://www.sqlite.org/c3ref/prepare.html\"><code>sqlite3_prepare_v2()</code></a>.</p>"
            },
            {
              "textRaw": "`database.createSession([options])`",
              "type": "method",
              "name": "createSession",
              "meta": {
                "added": [
                  "v23.3.0",
                  "v22.12.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Session} A session handle.",
                    "name": "return",
                    "type": "Session",
                    "desc": "A session handle."
                  },
                  "params": [
                    {
                      "textRaw": "`options` {Object} The configuration options for the session.",
                      "name": "options",
                      "type": "Object",
                      "desc": "The configuration options for the session.",
                      "options": [
                        {
                          "textRaw": "`table` {string} A specific table to track changes for. By default, changes to all tables are tracked.",
                          "name": "table",
                          "type": "string",
                          "desc": "A specific table to track changes for. By default, changes to all tables are tracked."
                        },
                        {
                          "textRaw": "`db` {string} Name of the database to track. This is useful when multiple databases have been added using [`ATTACH DATABASE`][]. **Default**: `'main'`.",
                          "name": "db",
                          "type": "string",
                          "desc": "Name of the database to track. This is useful when multiple databases have been added using [`ATTACH DATABASE`][]. **Default**: `'main'`."
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>Creates and attaches a session to the database. This method is a wrapper around <a href=\"https://www.sqlite.org/session/sqlite3session_create.html\"><code>sqlite3session_create()</code></a> and <a href=\"https://www.sqlite.org/session/sqlite3session_attach.html\"><code>sqlite3session_attach()</code></a>.</p>"
            },
            {
              "textRaw": "`database.applyChangeset(changeset[, options])`",
              "type": "method",
              "name": "applyChangeset",
              "meta": {
                "added": [
                  "v23.3.0",
                  "v22.12.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {boolean} Whether the changeset was applied successfully without being aborted.",
                    "name": "return",
                    "type": "boolean",
                    "desc": "Whether the changeset was applied successfully without being aborted."
                  },
                  "params": [
                    {
                      "textRaw": "`changeset` {Uint8Array} A binary changeset or patchset.",
                      "name": "changeset",
                      "type": "Uint8Array",
                      "desc": "A binary changeset or patchset."
                    },
                    {
                      "textRaw": "`options` {Object} The configuration options for how the changes will be applied.",
                      "name": "options",
                      "type": "Object",
                      "desc": "The configuration options for how the changes will be applied.",
                      "options": [
                        {
                          "textRaw": "`filter` {Function} Skip changes that, when targeted table name is supplied to this function, return a truthy value. By default, all changes are attempted.",
                          "name": "filter",
                          "type": "Function",
                          "desc": "Skip changes that, when targeted table name is supplied to this function, return a truthy value. By default, all changes are attempted."
                        },
                        {
                          "textRaw": "`onConflict` {Function} A function that determines how to handle conflicts. The function receives one argument, which can be one of the following values:The function should return one of the following values:When an error is thrown in the conflict handler or when any other value is returned from the handler, applying the changeset is aborted and the database is rolled back.**Default**: A function that returns `SQLITE_CHANGESET_ABORT`.",
                          "name": "onConflict",
                          "type": "Function",
                          "desc": "A function that determines how to handle conflicts. The function receives one argument, which can be one of the following values:The function should return one of the following values:When an error is thrown in the conflict handler or when any other value is returned from the handler, applying the changeset is aborted and the database is rolled back.**Default**: A function that returns `SQLITE_CHANGESET_ABORT`.",
                          "options": [
                            {
                              "textRaw": "`SQLITE_CHANGESET_DATA`: A `DELETE` or `UPDATE` change does not contain the expected \"before\" values.",
                              "name": "SQLITE_CHANGESET_DATA",
                              "desc": "A `DELETE` or `UPDATE` change does not contain the expected \"before\" values."
                            },
                            {
                              "textRaw": "`SQLITE_CHANGESET_NOTFOUND`: A row matching the primary key of the `DELETE` or `UPDATE` change does not exist.",
                              "name": "SQLITE_CHANGESET_NOTFOUND",
                              "desc": "A row matching the primary key of the `DELETE` or `UPDATE` change does not exist."
                            },
                            {
                              "textRaw": "`SQLITE_CHANGESET_CONFLICT`: An `INSERT` change results in a duplicate primary key.",
                              "name": "SQLITE_CHANGESET_CONFLICT",
                              "desc": "An `INSERT` change results in a duplicate primary key."
                            },
                            {
                              "textRaw": "`SQLITE_CHANGESET_FOREIGN_KEY`: Applying a change would result in a foreign key violation.",
                              "name": "SQLITE_CHANGESET_FOREIGN_KEY",
                              "desc": "Applying a change would result in a foreign key violation."
                            },
                            {
                              "textRaw": "`SQLITE_CHANGESET_CONSTRAINT`: Applying a change results in a `UNIQUE`, `CHECK`, or `NOT NULL` constraint violation.",
                              "name": "SQLITE_CHANGESET_CONSTRAINT",
                              "desc": "Applying a change results in a `UNIQUE`, `CHECK`, or `NOT NULL` constraint violation."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>An exception is thrown if the database is not\nopen. This method is a wrapper around <a href=\"https://www.sqlite.org/session/sqlite3changeset_apply.html\"><code>sqlite3changeset_apply()</code></a>.</p>\n<pre><code class=\"language-js\">const sourceDb = new DatabaseSync(':memory:');\nconst targetDb = new DatabaseSync(':memory:');\n\nsourceDb.exec('CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)');\ntargetDb.exec('CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)');\n\nconst session = sourceDb.createSession();\n\nconst insert = sourceDb.prepare('INSERT INTO data (key, value) VALUES (?, ?)');\ninsert.run(1, 'hello');\ninsert.run(2, 'world');\n\nconst changeset = session.changeset();\ntargetDb.applyChangeset(changeset);\n// Now that the changeset has been applied, targetDb contains the same data as sourceDb.\n</code></pre>"
            },
            {
              "textRaw": "`database[Symbol.dispose]()`",
              "type": "method",
              "name": "[Symbol.dispose]",
              "meta": {
                "added": [
                  "v23.11.0",
                  "v22.15.0"
                ],
                "changes": []
              },
              "stability": 1,
              "stabilityText": "Experimental",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Closes the database connection. If the database connection is already closed\nthen this is a no-op.</p>"
            }
          ],
          "properties": [
            {
              "textRaw": "`isOpen` {boolean} Whether the database is currently open or not.",
              "type": "boolean",
              "name": "isOpen",
              "meta": {
                "added": [
                  "v23.11.0",
                  "v22.15.0"
                ],
                "changes": []
              },
              "desc": "Whether the database is currently open or not."
            },
            {
              "textRaw": "`isTransaction` {boolean} Whether the database is currently within a transaction. This method is a wrapper around [`sqlite3_get_autocommit()`][].",
              "type": "boolean",
              "name": "isTransaction",
              "meta": {
                "added": [
                  "v24.0.0"
                ],
                "changes": []
              },
              "desc": "Whether the database is currently within a transaction. This method is a wrapper around [`sqlite3_get_autocommit()`][]."
            }
          ],
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`path` {string | Buffer | URL} The path of the database. A SQLite database can be stored in a file or completely [in memory][]. To use a file-backed database, the path should be a file path. To use an in-memory database, the path should be the special name `':memory:'`.",
                  "name": "path",
                  "type": "string | Buffer | URL",
                  "desc": "The path of the database. A SQLite database can be stored in a file or completely [in memory][]. To use a file-backed database, the path should be a file path. To use an in-memory database, the path should be the special name `':memory:'`."
                },
                {
                  "textRaw": "`options` {Object} Configuration options for the database connection. The following options are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Configuration options for the database connection. The following options are supported:",
                  "options": [
                    {
                      "textRaw": "`open` {boolean} If `true`, the database is opened by the constructor. When this value is `false`, the database must be opened via the `open()` method. **Default:** `true`.",
                      "name": "open",
                      "type": "boolean",
                      "default": "`true`",
                      "desc": "If `true`, the database is opened by the constructor. When this value is `false`, the database must be opened via the `open()` method."
                    },
                    {
                      "textRaw": "`readOnly` {boolean} If `true`, the database is opened in read-only mode. If the database does not exist, opening it will fail. **Default:** `false`.",
                      "name": "readOnly",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If `true`, the database is opened in read-only mode. If the database does not exist, opening it will fail."
                    },
                    {
                      "textRaw": "`enableForeignKeyConstraints` {boolean} If `true`, foreign key constraints are enabled. This is recommended but can be disabled for compatibility with legacy database schemas. The enforcement of foreign key constraints can be enabled and disabled after opening the database using [`PRAGMA foreign_keys`][]. **Default:** `true`.",
                      "name": "enableForeignKeyConstraints",
                      "type": "boolean",
                      "default": "`true`",
                      "desc": "If `true`, foreign key constraints are enabled. This is recommended but can be disabled for compatibility with legacy database schemas. The enforcement of foreign key constraints can be enabled and disabled after opening the database using [`PRAGMA foreign_keys`][]."
                    },
                    {
                      "textRaw": "`enableDoubleQuotedStringLiterals` {boolean} If `true`, SQLite will accept [double-quoted string literals][]. This is not recommended but can be enabled for compatibility with legacy database schemas. **Default:** `false`.",
                      "name": "enableDoubleQuotedStringLiterals",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If `true`, SQLite will accept [double-quoted string literals][]. This is not recommended but can be enabled for compatibility with legacy database schemas."
                    },
                    {
                      "textRaw": "`allowExtension` {boolean} If `true`, the `loadExtension` SQL function and the `loadExtension()` method are enabled. You can call `enableLoadExtension(false)` later to disable this feature. **Default:** `false`.",
                      "name": "allowExtension",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If `true`, the `loadExtension` SQL function and the `loadExtension()` method are enabled. You can call `enableLoadExtension(false)` later to disable this feature."
                    },
                    {
                      "textRaw": "`timeout` {number} The [busy timeout][] in milliseconds. This is the maximum amount of time that SQLite will wait for a database lock to be released before returning an error. **Default:** `0`.",
                      "name": "timeout",
                      "type": "number",
                      "default": "`0`",
                      "desc": "The [busy timeout][] in milliseconds. This is the maximum amount of time that SQLite will wait for a database lock to be released before returning an error."
                    }
                  ]
                }
              ],
              "desc": "<p>Constructs a new <code>DatabaseSync</code> instance.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `Session`",
          "type": "class",
          "name": "Session",
          "meta": {
            "added": [
              "v23.3.0",
              "v22.12.0"
            ],
            "changes": []
          },
          "methods": [
            {
              "textRaw": "`session.changeset()`",
              "type": "method",
              "name": "changeset",
              "meta": {
                "added": [
                  "v23.3.0",
                  "v22.12.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Uint8Array} Binary changeset that can be applied to other databases.",
                    "name": "return",
                    "type": "Uint8Array",
                    "desc": "Binary changeset that can be applied to other databases."
                  },
                  "params": []
                }
              ],
              "desc": "<p>Retrieves a changeset containing all changes since the changeset was created. Can be called multiple times.\nAn exception is thrown if the database or the session is not open. This method is a wrapper around <a href=\"https://www.sqlite.org/session/sqlite3session_changeset.html\"><code>sqlite3session_changeset()</code></a>.</p>"
            },
            {
              "textRaw": "`session.patchset()`",
              "type": "method",
              "name": "patchset",
              "meta": {
                "added": [
                  "v23.3.0",
                  "v22.12.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Uint8Array} Binary patchset that can be applied to other databases.",
                    "name": "return",
                    "type": "Uint8Array",
                    "desc": "Binary patchset that can be applied to other databases."
                  },
                  "params": []
                }
              ],
              "desc": "<p>Similar to the method above, but generates a more compact patchset. See <a href=\"https://www.sqlite.org/sessionintro.html#changesets_and_patchsets\">Changesets and Patchsets</a>\nin the documentation of SQLite. An exception is thrown if the database or the session is not open. This method is a\nwrapper around <a href=\"https://www.sqlite.org/session/sqlite3session_patchset.html\"><code>sqlite3session_patchset()</code></a>.</p>"
            }
          ],
          "modules": [
            {
              "textRaw": "`session.close()`.",
              "name": "`session.close()`.",
              "desc": "<p>Closes the session. An exception is thrown if the database or the session is not open. This method is a\nwrapper around <a href=\"https://www.sqlite.org/session/sqlite3session_delete.html\"><code>sqlite3session_delete()</code></a>.</p>",
              "type": "module",
              "displayName": "`session.close()`."
            }
          ]
        },
        {
          "textRaw": "Class: `StatementSync`",
          "type": "class",
          "name": "StatementSync",
          "meta": {
            "added": [
              "v22.5.0"
            ],
            "changes": []
          },
          "desc": "<p>This class represents a single <a href=\"https://www.sqlite.org/c3ref/stmt.html\">prepared statement</a>. This class cannot be\ninstantiated via its constructor. Instead, instances are created via the\n<code>database.prepare()</code> method. All APIs exposed by this class execute\nsynchronously.</p>\n<p>A prepared statement is an efficient binary representation of the SQL used to\ncreate it. Prepared statements are parameterizable, and can be invoked multiple\ntimes with different bound values. Parameters also offer protection against\n<a href=\"https://en.wikipedia.org/wiki/SQL_injection\">SQL injection</a> attacks. For these reasons, prepared statements are preferred\nover hand-crafted SQL strings when handling user input.</p>",
          "methods": [
            {
              "textRaw": "`statement.all([namedParameters][, ...anonymousParameters])`",
              "type": "method",
              "name": "all",
              "meta": {
                "added": [
                  "v22.5.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v23.7.0",
                      "v22.14.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/56385",
                    "description": "Add support for `DataView` and typed array objects for `anonymousParameters`."
                  }
                ]
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Array} An array of objects. Each object corresponds to a row returned by executing the prepared statement. The keys and values of each object correspond to the column names and values of the row.",
                    "name": "return",
                    "type": "Array",
                    "desc": "An array of objects. Each object corresponds to a row returned by executing the prepared statement. The keys and values of each object correspond to the column names and values of the row."
                  },
                  "params": [
                    {
                      "textRaw": "`namedParameters` {Object} An optional object used to bind named parameters. The keys of this object are used to configure the mapping.",
                      "name": "namedParameters",
                      "type": "Object",
                      "desc": "An optional object used to bind named parameters. The keys of this object are used to configure the mapping."
                    },
                    {
                      "textRaw": "`...anonymousParameters` {null|number|bigint|string|Buffer|TypedArray|DataView} Zero or more values to bind to anonymous parameters.",
                      "name": "...anonymousParameters",
                      "type": "null|number|bigint|string|Buffer|TypedArray|DataView",
                      "desc": "Zero or more values to bind to anonymous parameters."
                    }
                  ]
                }
              ],
              "desc": "<p>This method executes a prepared statement and returns all results as an array of\nobjects. If the prepared statement does not return any results, this method\nreturns an empty array. The prepared statement <a href=\"https://www.sqlite.org/c3ref/bind_blob.html\">parameters are bound</a> using\nthe values in <code>namedParameters</code> and <code>anonymousParameters</code>.</p>"
            },
            {
              "textRaw": "`statement.columns()`",
              "type": "method",
              "name": "columns",
              "meta": {
                "added": [
                  "v23.11.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Array} An array of objects. Each object corresponds to a column in the prepared statement, and contains the following properties:",
                    "name": "return",
                    "type": "Array",
                    "desc": "An array of objects. Each object corresponds to a column in the prepared statement, and contains the following properties:",
                    "options": [
                      {
                        "textRaw": "`column`: {string|null} The unaliased name of the column in the origin table, or `null` if the column is the result of an expression or subquery. This property is the result of [`sqlite3_column_origin_name()`][].",
                        "name": "column",
                        "type": "string|null",
                        "desc": "The unaliased name of the column in the origin table, or `null` if the column is the result of an expression or subquery. This property is the result of [`sqlite3_column_origin_name()`][]."
                      },
                      {
                        "textRaw": "`database`: {string|null} The unaliased name of the origin database, or `null` if the column is the result of an expression or subquery. This property is the result of [`sqlite3_column_database_name()`][].",
                        "name": "database",
                        "type": "string|null",
                        "desc": "The unaliased name of the origin database, or `null` if the column is the result of an expression or subquery. This property is the result of [`sqlite3_column_database_name()`][]."
                      },
                      {
                        "textRaw": "`name`: {string} The name assigned to the column in the result set of a `SELECT` statement. This property is the result of [`sqlite3_column_name()`][].",
                        "name": "name",
                        "type": "string",
                        "desc": "The name assigned to the column in the result set of a `SELECT` statement. This property is the result of [`sqlite3_column_name()`][]."
                      },
                      {
                        "textRaw": "`table`: {string|null} The unaliased name of the origin table, or `null` if the column is the result of an expression or subquery. This property is the result of [`sqlite3_column_table_name()`][].",
                        "name": "table",
                        "type": "string|null",
                        "desc": "The unaliased name of the origin table, or `null` if the column is the result of an expression or subquery. This property is the result of [`sqlite3_column_table_name()`][]."
                      },
                      {
                        "textRaw": "`type`: {string|null} The declared data type of the column, or `null` if the column is the result of an expression or subquery. This property is the result of [`sqlite3_column_decltype()`][].",
                        "name": "type",
                        "type": "string|null",
                        "desc": "The declared data type of the column, or `null` if the column is the result of an expression or subquery. This property is the result of [`sqlite3_column_decltype()`][]."
                      }
                    ]
                  },
                  "params": []
                }
              ],
              "desc": "<p>This method is used to retrieve information about the columns returned by the\nprepared statement.</p>"
            },
            {
              "textRaw": "`statement.get([namedParameters][, ...anonymousParameters])`",
              "type": "method",
              "name": "get",
              "meta": {
                "added": [
                  "v22.5.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v23.7.0",
                      "v22.14.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/56385",
                    "description": "Add support for `DataView` and typed array objects for `anonymousParameters`."
                  }
                ]
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Object|undefined} An object corresponding to the first row returned by executing the prepared statement. The keys and values of the object correspond to the column names and values of the row. If no rows were returned from the database then this method returns `undefined`.",
                    "name": "return",
                    "type": "Object|undefined",
                    "desc": "An object corresponding to the first row returned by executing the prepared statement. The keys and values of the object correspond to the column names and values of the row. If no rows were returned from the database then this method returns `undefined`."
                  },
                  "params": [
                    {
                      "textRaw": "`namedParameters` {Object} An optional object used to bind named parameters. The keys of this object are used to configure the mapping.",
                      "name": "namedParameters",
                      "type": "Object",
                      "desc": "An optional object used to bind named parameters. The keys of this object are used to configure the mapping."
                    },
                    {
                      "textRaw": "`...anonymousParameters` {null|number|bigint|string|Buffer|TypedArray|DataView} Zero or more values to bind to anonymous parameters.",
                      "name": "...anonymousParameters",
                      "type": "null|number|bigint|string|Buffer|TypedArray|DataView",
                      "desc": "Zero or more values to bind to anonymous parameters."
                    }
                  ]
                }
              ],
              "desc": "<p>This method executes a prepared statement and returns the first result as an\nobject. If the prepared statement does not return any results, this method\nreturns <code>undefined</code>. The prepared statement <a href=\"https://www.sqlite.org/c3ref/bind_blob.html\">parameters are bound</a> using the\nvalues in <code>namedParameters</code> and <code>anonymousParameters</code>.</p>"
            },
            {
              "textRaw": "`statement.iterate([namedParameters][, ...anonymousParameters])`",
              "type": "method",
              "name": "iterate",
              "meta": {
                "added": [
                  "v23.4.0",
                  "v22.13.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v23.7.0",
                      "v22.14.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/56385",
                    "description": "Add support for `DataView` and typed array objects for `anonymousParameters`."
                  }
                ]
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Iterator} An iterable iterator of objects. Each object corresponds to a row returned by executing the prepared statement. The keys and values of each object correspond to the column names and values of the row.",
                    "name": "return",
                    "type": "Iterator",
                    "desc": "An iterable iterator of objects. Each object corresponds to a row returned by executing the prepared statement. The keys and values of each object correspond to the column names and values of the row."
                  },
                  "params": [
                    {
                      "textRaw": "`namedParameters` {Object} An optional object used to bind named parameters. The keys of this object are used to configure the mapping.",
                      "name": "namedParameters",
                      "type": "Object",
                      "desc": "An optional object used to bind named parameters. The keys of this object are used to configure the mapping."
                    },
                    {
                      "textRaw": "`...anonymousParameters` {null|number|bigint|string|Buffer|TypedArray|DataView} Zero or more values to bind to anonymous parameters.",
                      "name": "...anonymousParameters",
                      "type": "null|number|bigint|string|Buffer|TypedArray|DataView",
                      "desc": "Zero or more values to bind to anonymous parameters."
                    }
                  ]
                }
              ],
              "desc": "<p>This method executes a prepared statement and returns an iterator of\nobjects. If the prepared statement does not return any results, this method\nreturns an empty iterator. The prepared statement <a href=\"https://www.sqlite.org/c3ref/bind_blob.html\">parameters are bound</a> using\nthe values in <code>namedParameters</code> and <code>anonymousParameters</code>.</p>"
            },
            {
              "textRaw": "`statement.run([namedParameters][, ...anonymousParameters])`",
              "type": "method",
              "name": "run",
              "meta": {
                "added": [
                  "v22.5.0"
                ],
                "changes": [
                  {
                    "version": [
                      "v23.7.0",
                      "v22.14.0"
                    ],
                    "pr-url": "https://github.com/nodejs/node/pull/56385",
                    "description": "Add support for `DataView` and typed array objects for `anonymousParameters`."
                  }
                ]
              },
              "signatures": [
                {
                  "return": {
                    "textRaw": "Returns: {Object}",
                    "name": "return",
                    "type": "Object",
                    "options": [
                      {
                        "textRaw": "`changes`: {number|bigint} The number of rows modified, inserted, or deleted by the most recently completed `INSERT`, `UPDATE`, or `DELETE` statement. This field is either a number or a `BigInt` depending on the prepared statement's configuration. This property is the result of [`sqlite3_changes64()`][].",
                        "name": "changes",
                        "type": "number|bigint",
                        "desc": "The number of rows modified, inserted, or deleted by the most recently completed `INSERT`, `UPDATE`, or `DELETE` statement. This field is either a number or a `BigInt` depending on the prepared statement's configuration. This property is the result of [`sqlite3_changes64()`][]."
                      },
                      {
                        "textRaw": "`lastInsertRowid`: {number|bigint} The most recently inserted rowid. This field is either a number or a `BigInt` depending on the prepared statement's configuration. This property is the result of [`sqlite3_last_insert_rowid()`][].",
                        "name": "lastInsertRowid",
                        "type": "number|bigint",
                        "desc": "The most recently inserted rowid. This field is either a number or a `BigInt` depending on the prepared statement's configuration. This property is the result of [`sqlite3_last_insert_rowid()`][]."
                      }
                    ]
                  },
                  "params": [
                    {
                      "textRaw": "`namedParameters` {Object} An optional object used to bind named parameters. The keys of this object are used to configure the mapping.",
                      "name": "namedParameters",
                      "type": "Object",
                      "desc": "An optional object used to bind named parameters. The keys of this object are used to configure the mapping."
                    },
                    {
                      "textRaw": "`...anonymousParameters` {null|number|bigint|string|Buffer|TypedArray|DataView} Zero or more values to bind to anonymous parameters.",
                      "name": "...anonymousParameters",
                      "type": "null|number|bigint|string|Buffer|TypedArray|DataView",
                      "desc": "Zero or more values to bind to anonymous parameters."
                    }
                  ]
                }
              ],
              "desc": "<p>This method executes a prepared statement and returns an object summarizing the\nresulting changes. The prepared statement <a href=\"https://www.sqlite.org/c3ref/bind_blob.html\">parameters are bound</a> using the\nvalues in <code>namedParameters</code> and <code>anonymousParameters</code>.</p>"
            },
            {
              "textRaw": "`statement.setAllowBareNamedParameters(enabled)`",
              "type": "method",
              "name": "setAllowBareNamedParameters",
              "meta": {
                "added": [
                  "v22.5.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`enabled` {boolean} Enables or disables support for binding named parameters without the prefix character.",
                      "name": "enabled",
                      "type": "boolean",
                      "desc": "Enables or disables support for binding named parameters without the prefix character."
                    }
                  ]
                }
              ],
              "desc": "<p>The names of SQLite parameters begin with a prefix character. By default,\n<code>node:sqlite</code> requires that this prefix character is present when binding\nparameters. However, with the exception of dollar sign character, these\nprefix characters also require extra quoting when used in object keys.</p>\n<p>To improve ergonomics, this method can be used to also allow bare named\nparameters, which do not require the prefix character in JavaScript code. There\nare several caveats to be aware of when enabling bare named parameters:</p>\n<ul>\n<li>The prefix character is still required in SQL.</li>\n<li>The prefix character is still allowed in JavaScript. In fact, prefixed names\nwill have slightly better binding performance.</li>\n<li>Using ambiguous named parameters, such as <code>$k</code> and <code>@k</code>, in the same prepared\nstatement will result in an exception as it cannot be determined how to bind\na bare name.</li>\n</ul>"
            },
            {
              "textRaw": "`statement.setAllowUnknownNamedParameters(enabled)`",
              "type": "method",
              "name": "setAllowUnknownNamedParameters",
              "meta": {
                "added": [
                  "v23.11.0",
                  "v22.15.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`enabled` {boolean} Enables or disables support for unknown named parameters.",
                      "name": "enabled",
                      "type": "boolean",
                      "desc": "Enables or disables support for unknown named parameters."
                    }
                  ]
                }
              ],
              "desc": "<p>By default, if an unknown name is encountered while binding parameters, an\nexception is thrown. This method allows unknown named parameters to be ignored.</p>"
            },
            {
              "textRaw": "`statement.setReadBigInts(enabled)`",
              "type": "method",
              "name": "setReadBigInts",
              "meta": {
                "added": [
                  "v22.5.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`enabled` {boolean} Enables or disables the use of `BigInt`s when reading `INTEGER` fields from the database.",
                      "name": "enabled",
                      "type": "boolean",
                      "desc": "Enables or disables the use of `BigInt`s when reading `INTEGER` fields from the database."
                    }
                  ]
                }
              ],
              "desc": "<p>When reading from the database, SQLite <code>INTEGER</code>s are mapped to JavaScript\nnumbers by default. However, SQLite <code>INTEGER</code>s can store values larger than\nJavaScript numbers are capable of representing. In such cases, this method can\nbe used to read <code>INTEGER</code> data using JavaScript <code>BigInt</code>s. This method has no\nimpact on database write operations where numbers and <code>BigInt</code>s are both\nsupported at all times.</p>"
            }
          ],
          "properties": [
            {
              "textRaw": "`expandedSQL` {string} The source SQL expanded to include parameter values.",
              "type": "string",
              "name": "expandedSQL",
              "meta": {
                "added": [
                  "v22.5.0"
                ],
                "changes": []
              },
              "desc": "<p>The source SQL text of the prepared statement with parameter\nplaceholders replaced by the values that were used during the most recent\nexecution of this prepared statement. This property is a wrapper around\n<a href=\"https://www.sqlite.org/c3ref/expanded_sql.html\"><code>sqlite3_expanded_sql()</code></a>.</p>",
              "shortDesc": "The source SQL expanded to include parameter values."
            },
            {
              "textRaw": "`sourceSQL` {string} The source SQL used to create this prepared statement.",
              "type": "string",
              "name": "sourceSQL",
              "meta": {
                "added": [
                  "v22.5.0"
                ],
                "changes": []
              },
              "desc": "<p>The source SQL text of the prepared statement. This property is a\nwrapper around <a href=\"https://www.sqlite.org/c3ref/expanded_sql.html\"><code>sqlite3_sql()</code></a>.</p>",
              "shortDesc": "The source SQL used to create this prepared statement."
            }
          ],
          "modules": [
            {
              "textRaw": "Type conversion between JavaScript and SQLite",
              "name": "type_conversion_between_javascript_and_sqlite",
              "desc": "<p>When Node.js writes to or reads from SQLite it is necessary to convert between\nJavaScript data types and SQLite's <a href=\"https://www.sqlite.org/datatype3.html\">data types</a>. Because JavaScript supports\nmore data types than SQLite, only a subset of JavaScript types are supported.\nAttempting to write an unsupported data type to SQLite will result in an\nexception.</p>\n<table>\n<thead>\n<tr>\n<th>SQLite</th>\n<th>JavaScript</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>NULL</code></td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Null_type\" class=\"type\">&lt;null&gt;</a></td>\n</tr>\n<tr>\n<td><code>INTEGER</code></td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a> or <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt\" class=\"type\">&lt;bigint&gt;</a></td>\n</tr>\n<tr>\n<td><code>REAL</code></td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></td>\n</tr>\n<tr>\n<td><code>TEXT</code></td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\">&lt;string&gt;</a></td>\n</tr>\n<tr>\n<td><code>BLOB</code></td>\n<td><a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray\" class=\"type\">&lt;TypedArray&gt;</a> or <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView\" class=\"type\">&lt;DataView&gt;</a></td>\n</tr>\n</tbody>\n</table>",
              "type": "module",
              "displayName": "Type conversion between JavaScript and SQLite"
            }
          ]
        }
      ],
      "methods": [
        {
          "textRaw": "`sqlite.backup(sourceDb, path[, options])`",
          "type": "method",
          "name": "backup",
          "meta": {
            "added": [
              "v23.8.0"
            ],
            "changes": [
              {
                "version": "v23.10.0",
                "pr-url": "https://github.com/nodejs/node/pull/56991",
                "description": "The `path` argument now supports Buffer and URL objects."
              }
            ]
          },
          "signatures": [
            {
              "return": {
                "textRaw": "Returns: {Promise} A promise that resolves when the backup is completed and rejects if an error occurs.",
                "name": "return",
                "type": "Promise",
                "desc": "A promise that resolves when the backup is completed and rejects if an error occurs."
              },
              "params": [
                {
                  "textRaw": "`sourceDb` {DatabaseSync} The database to backup. The source database must be open.",
                  "name": "sourceDb",
                  "type": "DatabaseSync",
                  "desc": "The database to backup. The source database must be open."
                },
                {
                  "textRaw": "`path` {string | Buffer | URL} The path where the backup will be created. If the file already exists, the contents will be overwritten.",
                  "name": "path",
                  "type": "string | Buffer | URL",
                  "desc": "The path where the backup will be created. If the file already exists, the contents will be overwritten."
                },
                {
                  "textRaw": "`options` {Object} Optional configuration for the backup. The following properties are supported:",
                  "name": "options",
                  "type": "Object",
                  "desc": "Optional configuration for the backup. The following properties are supported:",
                  "options": [
                    {
                      "textRaw": "`source` {string} Name of the source database. This can be `'main'` (the default primary database) or any other database that have been added with [`ATTACH DATABASE`][] **Default:** `'main'`.",
                      "name": "source",
                      "type": "string",
                      "default": "`'main'`",
                      "desc": "Name of the source database. This can be `'main'` (the default primary database) or any other database that have been added with [`ATTACH DATABASE`][]"
                    },
                    {
                      "textRaw": "`target` {string} Name of the target database. This can be `'main'` (the default primary database) or any other database that have been added with [`ATTACH DATABASE`][] **Default:** `'main'`.",
                      "name": "target",
                      "type": "string",
                      "default": "`'main'`",
                      "desc": "Name of the target database. This can be `'main'` (the default primary database) or any other database that have been added with [`ATTACH DATABASE`][]"
                    },
                    {
                      "textRaw": "`rate` {number} Number of pages to be transmitted in each batch of the backup. **Default:** `100`.",
                      "name": "rate",
                      "type": "number",
                      "default": "`100`",
                      "desc": "Number of pages to be transmitted in each batch of the backup."
                    },
                    {
                      "textRaw": "`progress` {Function} Callback function that will be called with the number of pages copied and the total number of pages.",
                      "name": "progress",
                      "type": "Function",
                      "desc": "Callback function that will be called with the number of pages copied and the total number of pages."
                    }
                  ]
                }
              ]
            }
          ],
          "desc": "<p>This method makes a database backup. This method abstracts the <a href=\"https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupinit\"><code>sqlite3_backup_init()</code></a>, <a href=\"https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupstep\"><code>sqlite3_backup_step()</code></a>\nand <a href=\"https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupfinish\"><code>sqlite3_backup_finish()</code></a> functions.</p>\n<p>The backed-up database can be used normally during the backup process. Mutations coming from the same connection - same\n<a href=\"sqlite.html#class-databasesync\" class=\"type\">&lt;DatabaseSync&gt;</a> - object will be reflected in the backup right away. However, mutations from other connections will cause\nthe backup process to restart.</p>\n<pre><code class=\"language-cjs\">const { backup, DatabaseSync } = require('node:sqlite');\n\n(async () => {\n  const sourceDb = new DatabaseSync('source.db');\n  const totalPagesTransferred = await backup(sourceDb, 'backup.db', {\n    rate: 1, // Copy one page at a time.\n    progress: ({ totalPages, remainingPages }) => {\n      console.log('Backup in progress', { totalPages, remainingPages });\n    },\n  });\n\n  console.log('Backup completed', totalPagesTransferred);\n})();\n</code></pre>\n<pre><code class=\"language-mjs\">import { backup, DatabaseSync } from 'node:sqlite';\n\nconst sourceDb = new DatabaseSync('source.db');\nconst totalPagesTransferred = await backup(sourceDb, 'backup.db', {\n  rate: 1, // Copy one page at a time.\n  progress: ({ totalPages, remainingPages }) => {\n    console.log('Backup in progress', { totalPages, remainingPages });\n  },\n});\n\nconsole.log('Backup completed', totalPagesTransferred);\n</code></pre>"
        }
      ],
      "properties": [
        {
          "textRaw": "`constants` {Object}",
          "type": "Object",
          "name": "constants",
          "meta": {
            "added": [
              "v23.5.0",
              "v22.13.0"
            ],
            "changes": []
          },
          "desc": "<p>An object containing commonly used constants for SQLite operations.</p>",
          "modules": [
            {
              "textRaw": "SQLite constants",
              "name": "sqlite_constants",
              "desc": "<p>The following constants are exported by the <code>sqlite.constants</code> object.</p>",
              "modules": [
                {
                  "textRaw": "Conflict resolution constants",
                  "name": "conflict_resolution_constants",
                  "desc": "<p>One of the following constants is available as an argument to the <code>onConflict</code>\nconflict resolution handler passed to <a href=\"#databaseapplychangesetchangeset-options\"><code>database.applyChangeset()</code></a>. See also\n<a href=\"https://www.sqlite.org/session/c_changeset_conflict.html\">Constants Passed To The Conflict Handler</a> in the SQLite documentation.</p>\n<table>\n  <tr>\n    <th>Constant</th>\n    <th>Description</th>\n  </tr>\n  <tr>\n    <td><code>SQLITE_CHANGESET_DATA</code></td>\n    <td>The conflict handler is invoked with this constant when processing a DELETE or UPDATE change if a row with the required PRIMARY KEY fields is present in the database, but one or more other (non primary-key) fields modified by the update do not contain the expected \"before\" values.</td>\n  </tr>\n  <tr>\n    <td><code>SQLITE_CHANGESET_NOTFOUND</code></td>\n    <td>The conflict handler is invoked with this constant when processing a DELETE or UPDATE change if a row with the required PRIMARY KEY fields is not present in the database.</td>\n  </tr>\n  <tr>\n    <td><code>SQLITE_CHANGESET_CONFLICT</code></td>\n    <td>This constant is passed to the conflict handler while processing an INSERT change if the operation would result in duplicate primary key values.</td>\n  </tr>\n  <tr>\n    <td><code>SQLITE_CHANGESET_CONSTRAINT</code></td>\n    <td>If foreign key handling is enabled, and applying a changeset leaves the database in a state containing foreign key violations, the conflict handler is invoked with this constant exactly once before the changeset is committed. If the conflict handler returns <code>SQLITE_CHANGESET_OMIT</code>, the changes, including those that caused the foreign key constraint violation, are committed. Or, if it returns <code>SQLITE_CHANGESET_ABORT</code>, the changeset is rolled back.</td>\n  </tr>\n  <tr>\n    <td><code>SQLITE_CHANGESET_FOREIGN_KEY</code></td>\n    <td>If any other constraint violation occurs while applying a change (i.e. a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is invoked with this constant.</td>\n  </tr>\n</table>\n<p>One of the following constants must be returned from the <code>onConflict</code> conflict\nresolution handler passed to <a href=\"#databaseapplychangesetchangeset-options\"><code>database.applyChangeset()</code></a>. See also\n<a href=\"https://www.sqlite.org/session/c_changeset_abort.html\">Constants Returned From The Conflict Handler</a> in the SQLite documentation.</p>\n<table>\n  <tr>\n    <th>Constant</th>\n    <th>Description</th>\n  </tr>\n  <tr>\n    <td><code>SQLITE_CHANGESET_OMIT</code></td>\n    <td>Conflicting changes are omitted.</td>\n  </tr>\n  <tr>\n    <td><code>SQLITE_CHANGESET_REPLACE</code></td>\n    <td>Conflicting changes replace existing values. Note that this value can only be returned when the type of conflict is either <code>SQLITE_CHANGESET_DATA</code> or <code>SQLITE_CHANGESET_CONFLICT</code>.</td>\n  </tr>\n  <tr>\n    <td><code>SQLITE_CHANGESET_ABORT</code></td>\n    <td>Abort when a change encounters a conflict and roll back database.</td>\n  </tr>\n</table>",
                  "type": "module",
                  "displayName": "Conflict resolution constants"
                }
              ],
              "type": "module",
              "displayName": "SQLite constants"
            }
          ]
        }
      ],
      "type": "module",
      "displayName": "SQLite"
    }
  ]
}