In order to use the xk6-sql API, in addition to the k6/x/sql module,
it is also necessary to import at least one driver module.
The default export of the driver module is a driver identifier symbol,
which should be passed as a parameter of the open() function.
The driver module is typically available at k6/x/sql/driver/FOO,
where FOO is the name of the driver.
Example
importsqlfrom"k6/x/sql";
// the actual database driver should be used instead of ramsql importdriverfrom"k6/x/sql/driver/ramsql";
constdb = sql.open(driver, "roster_db");
exportfunctionsetup() { db.exec(` CREATE TABLE IF NOT EXISTS roster ( id INTEGER PRIMARY KEY AUTOINCREMENT, given_name VARCHAR NOT NULL, family_name VARCHAR NOT NULL ); `); }
Use SQL databases from k6 tests.
xk6-sql is a Grafana k6 extension that enables the use of SQL databases in k6 tests.
In order to use the
xk6-sql
API, in addition to thek6/x/sql
module, it is also necessary to import at least one driver module. The default export of the driver module is a driver identifier symbol, which should be passed as a parameter of theopen()
function.The driver module is typically available at
k6/x/sql/driver/FOO
, whereFOO
is the name of the driver.Example