Execute the prepared statement.
method
sqlite.Statement.run
@param params
optional values to bind to the statement. If omitted, the statement is run with the last bound values or no parameters if there are none.
@returns
A Changes object with changes and lastInsertRowid properties
const insert = db.prepare("INSERT INTO users (name) VALUES (?)");
insert.run("Alice");
// => { changes: 1, lastInsertRowid: 1 }
insert.run("Bob");
// => { changes: 1, lastInsertRowid: 2 }
const update = db.prepare("UPDATE users SET name = ? WHERE id = ?");
update.run("Charlie", 1);
// => { changes: 1, lastInsertRowid: 2 }
The following types can be used when binding parameters:
| JavaScript type | SQLite type |
|---|---|
string | TEXT |
number | INTEGER or DECIMAL |
boolean | INTEGER (1 or 0) |
Uint8Array | BLOB |
Buffer | BLOB |
bigint | INTEGER |
null | NULL |
Referenced types
interface Changes
An object representing the changes made to the database since the last run or exec call.
- lastInsertRowid: number | bigint
If
safeIntegersistrue, this is abigint. Otherwise, it is anumber.