Interface Result

A Result summarizes an executed SQL command.

 import sql from "k6/x/sql";

// the actual database driver should be used instead of ramsql
import driver from "k6/x/sql/driver/ramsql";

const db = sql.open(driver, "roster_db");

export function setup() {
let result = db.exec(`
INSERT INTO roster
(given_name, family_name)
VALUES
('Peter', 'Pan'),
('Wendy', 'Darling'),
('Tinker', 'Bell'),
('James', 'Hook');
`);
console.log(`${result.rowsAffected()} rows inserted`);
}
interface Result {
    lastInsertId(): number;
    rowsAffected(): number;
}

Methods

  • Returns the integer generated by the database in response to a command. Typically this will be from an "auto increment" column when inserting a new row. Not all databases support this feature, and the syntax of such statements varies.

    Returns number

  • Returns the number of rows affected by an update, insert, or delete. Not every database or database driver may support this.

    Returns number