sql

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2025 License: Apache-2.0 Imports: 8 Imported by: 17

Documentation

Overview

Package sql provides a javascript module for performing SQL actions against relational databases.

Index

Constants

View Source
const ImportPath = "k6/x/sql"

ImportPath contains module's JavaScript import path.

Variables

This section is empty.

Functions

func New

func New() modules.Module

New creates a new instance of the extension's JavaScript module.

func RegisterDriver

func RegisterDriver(driverName string) *sobek.Symbol

RegisterDriver registers an SQL database driver.

func RegisterModule

func RegisterModule(driverName string) modules.Module

RegisterModule registers an SQL database driver module. The module import path will be k6/x/sql/driver/ + driverName. The module's default export will be the driver id Symbol.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database is a database handle representing a pool of zero or more underlying connections.

func (*Database) Close

func (dbase *Database) Close() error

Close the database and prevents new queries from starting.

func (*Database) Exec

func (dbase *Database) Exec(query string, args ...interface{}) (sql.Result, error)

Exec executes a query without returning any rows.

func (*Database) ExecWithTimeout added in v1.0.4

func (dbase *Database) ExecWithTimeout(timeout string, query string, args ...interface{}) (sql.Result, error)

ExecWithTimeout executes a query (with a timeout) without returning any rows. The timeout can be specified as a duration string.

func (*Database) Query

func (dbase *Database) Query(query string, args ...interface{}) ([]KeyValue, error)

Query executes a query that returns rows, typically a SELECT.

func (*Database) QueryWithTimeout added in v1.0.4

func (dbase *Database) QueryWithTimeout(timeout string, query string, args ...interface{}) ([]KeyValue, error)

QueryWithTimeout executes a query (with a timeout) that returns rows, typically a SELECT. The timeout can be specified as a duration string.

type KeyValue

type KeyValue map[string]interface{}

KeyValue is a simple key-value pair.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL