Interface Options

Connection-related options for the open function.

 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", { conn_max_idle_time: "2s" });
interface Options {
    conn_max_idle_time: string;
    conn_max_lifetime: string;
    max_idle_conns: number;
    max_open_conns: number;
}

Properties

conn_max_idle_time: string

Sets the maximum amount of time a connection may be idle. If 0, connections are not closed due to a connection's idle time. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

const db = sql.open(driver, "roster_db", { conn_max_idle_time: "1h10m10s" });
conn_max_lifetime: string

Sets the maximum amount of time a connection may be reused. If 0, connections are not closed due to a connection's age. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

const db = sql.open(driver, "roster_db", { conn_max_lifetime: "10h" });
max_idle_conns: number

Sets the maximum number of connections in the idle connection pool. If 0, no idle connections are retained. The default is currently 2.

const db = sql.open(driver, "roster_db", { max_idle_conns: 3 });
max_open_conns: number

Sets the maximum number of open connections to the database. If 0, then there is no limit on the number of open connections. The default is 0 (unlimited).

const db = sql.open(driver, "roster_db", { max_open_conns: 100 });