Skip to content

Latest commit

 

History

History
88 lines (61 loc) · 4.1 KB

sqlite.md

File metadata and controls

88 lines (61 loc) · 4.1 KB

sqlite

Source: quickjs-sqlite.c — module exports SQLite3, SQLite3Error, SQLite3Result

SQLite3 client (wraps libsqlite3).

SQLite3

new SQLite3()   // length 1

Methods

Method Args Description
open(filename) 1 Opens (or creates) a database file.
query(sql) 1 Runs a query; returns a SQLite3Result.
prepare(sql) 1 Prepares the first statement without running it; returns a SQLite3Result, or null for empty sql.
exec(sql) 1 Runs a statement without returning rows.
close() 0 Closes the connection.
escapeString(str) 1 Escapes a string for safe interpolation.
quoteString(str) 1 Quotes a string as an SQL literal.
valueString(value) 0 Renders one value as SQL.
valuesString(values) 1 Renders a value list as SQL.
insertQuery(table, row) 2 Builds an INSERT statement.

Properties (read-only)

affectedRows/changes, insertId/lastInsertRowid, totalChanges, errorMessage, errorCode, extendedErrorCode, filename, inTransaction.

Static members

Member Args Kind Description
escapeString(str) 1 function Static escaping helper.
quoteString(str) 1 function Static quoting helper.
valueString(value) 0 function Renders one value as SQL.

SQLite3Result

A result set; iterable.

Member Args Kind Description
fetchRow() 0 method Fetches the next row as an array.
fetchAssoc() 0 method Fetches the next row as an object.
fetchField(i) 1 method Returns metadata for one field.
fetchFields() 0 method Returns metadata for all fields.
reset() 0 method Resets the statement for re-execution.
bind(values, strict) 1 method Resets, then binds an array (positional) or an object (named, with prefix; strict also matches without).
finalize() 0 method Releases the statement now.
paramCount — getter Number of parameters of the statement.
resultType — property Flags for the rows: RESULT_OBJECT, RESULT_STRING, RESULT_BIGINT (integers as bigint), RESULT_BYTES (blobs as Uint8Array), RESULT_PLAIN (objects with Object.prototype).
eof — getter Whether all rows are consumed.
[Symbol.iterator] 0 method Row iteration.

SQLite3Error

Error subclass (name = "SQLite3Error") carrying SQLite error details.

Export list

Generated by utilities/doc-api.js from the sqlite dump of utilities/api-surface.sh: 73 members. Edit the text above this block, not the block.

SQLite3

class, constructible

  • static methods: escapeString(), quoteString(), valueString()
  • static values: BLOB = 4, FLOAT = 2, INTEGER = 1, NULL = 5, OPEN_CREATE = 4, OPEN_FULLMUTEX = 65536, OPEN_MEMORY = 128, OPEN_NOMUTEX = 32768, OPEN_PRIVATECACHE = 262144, OPEN_READONLY = 1, OPEN_READWRITE = 2, OPEN_SHAREDCACHE = 131072, OPEN_URI = 64, RESULT_OBJECT = 1, RESULT_STRING = 2, TEXT = 3
  • methods: close(), escapeString(), exec(), execute(), insertQuery(), open(), query(), quoteString(), valueString(), valuesString()
  • properties: BLOB = 4, FLOAT = 2, INTEGER = 1, NULL = 5, OPEN_CREATE = 4, OPEN_FULLMUTEX = 65536, OPEN_MEMORY = 128, OPEN_NOMUTEX = 32768, OPEN_PRIVATECACHE = 262144, OPEN_READONLY = 1, OPEN_READWRITE = 2, OPEN_SHAREDCACHE = 131072, OPEN_URI = 64, RESULT_OBJECT = 1, RESULT_STRING = 2, TEXT = 3, affectedRows (get), changes (get), errorCode (get), errorMessage (get), filename (get), insertId (get), lastInsertRowid (get), totalChanges (get), [Symbol.toStringTag]

SQLite3Error

class, constructible

  • properties: name, type = 0, [Symbol.toStringTag]

SQLite3Result

class, constructible

  • methods: fetchAssoc(), fetchField(), fetchFields(), fetchRow(), reset(), [Symbol.iterator]()
  • properties: eof (get), numFields (get), numRows (get), [Symbol.toStringTag]