{ } qjs-modules

mysql

Source: quickjs-mysql.c — module exports MySQL, MySQLError, MySQLResult

Asynchronous MySQL/MariaDB client (wraps libmysqlclient). Connection and query methods are non-blocking and return promises driven off the socket fd.

MySQL

new MySQL()   // length 1

Methods

MethodArgsDescription
connect(params)1Connects using {host, user, password, db, port, socket, …}; resolves when ready.
query(sql)1Runs a query; resolves to a MySQLResult (alias execute).
close()0Closes the connection.
escapeString(str)1Escapes a string for safe interpolation.
getOption(opt)1Reads a connection option.
setOption(opt, value)2Sets a connection option.

Properties (read-only)

moreResults, affectedRows, warningCount, fieldCount, fd/socket, errno, error, info, insertId, charset, timeout, timeoutMs, serverName, serverInfo, serverVersion, user, password, host, port, db, status, pending.

Static members

MemberArgsKindDescription
clientInfo—getterClient library info string.
clientVersion—getterClient library version.
threadSafe—getterWhether the client is thread-safe.
escapeString(str)1functionStatic escaping helper.
valueString(value)0functionRenders one value as SQL.
valuesString(values)1functionRenders a value list as SQL.
insertQuery(table, row)2functionBuilds an INSERT statement.

MySQLResult

A result set; iterable (sync and async).

MemberArgsKindDescription
next()0methodFetches the next row.
fetchRow()0methodFetches the next row as an array.
fetchAssoc()0methodFetches the next row as an object.
fetchField(i)1methodReturns metadata for one field.
fetchFields()0methodReturns metadata for all fields.
eof—getterWhether all rows are consumed.
numRows—getterRow count (enumerable).
numFields—getterField count (enumerable).
fieldCount—getterField count.
currentField—getterIndex of the current field.
[Symbol.iterator] / [Symbol.asyncIterator]0methodRow iteration.

MySQLError

Error subclass (name = "MySQLError") carrying MySQL error details.